Skip to content

[Feature] cordova-electron support#960

Draft
ikosta wants to merge 15 commits into
brody2consult:devfrom
ikosta:dev
Draft

[Feature] cordova-electron support#960
ikosta wants to merge 15 commits into
brody2consult:devfrom
ikosta:dev

Conversation

@ikosta

@ikosta ikosta commented Nov 19, 2020

Copy link
Copy Markdown

[DRAFT] WORK IN PROGRESS

I implemented the support for cordova-electron and there are a few things you need to know. I needed this to work on a production app we will release the next weeks. The app is an ionic 5 app with typeorm and it is tested on Browser, iOS, Android and Electron (Windows) right now.

I extended the browser proxy because we are using the electron nodeIntegration to have window.require in our client and run the node sqlite3 module.

Please feel free to ask me questions and let me know what you think about this solution.

Instructions:

  • Install cordova-electron@2.0.0 (it must be in the dependencies not devDependencies)
    cordova platform add electron@2.0.0 --save
  • Install sqlite3
    npm i sqlite3
  • You need to have nodeIntegration enabled in electron
    • Add electron-settings file in config.xml
    <platform name="electron">
        <preference name="ElectronSettingsFilePath" value="electron-settings.json" />
    </platform>
    
    • electron-settings.json in project-root
    {
      "browserWindow": {
        "webPreferences": {
          "nodeIntegration": true
        }
      }
    }
    
  • Now you can use typeorm or this plugin to communicate with the database and it will persist the data after relaunch.

@brody2consult

Copy link
Copy Markdown
Owner

This looks really good in general, many thanks for the contribution.

I noticed that you made this contribution from your default "dev" branch. I would recommend that you consider using a more specific branch name for future PRs.

I find it a little too bad that someone has to manually install a separate dependency for the Electron platform. It would be ideal if we could figure out a decent way to make this more automatic. Maybe I am just dreaming here.

I am thinking it would also be ideal if we could find a way to make the "sqlite3" object more injectable. Maybe for a future iteration (someday).

Thanks again!

@bilal-elchami

Copy link
Copy Markdown

Any updates on the progress of this PR?

@pjoriginal

Copy link
Copy Markdown

Any progress on this?

@ikosta

ikosta commented Apr 23, 2023

Copy link
Copy Markdown
Author

This did go live in December of 2020 with an app from snapADDY called VisitReport. I believe it is still used there on production but we have to ask @SebastianMetzger CTO from snapADDY if it is still live and if there are issues at all.

@SebastianMetzger

Copy link
Copy Markdown

We are currently working on this fork of the repository in production which contains couple of additional commits on top of the once from this PR.
https://github.com/snapADDY/cordova-sqlite-storage/commits/dev

I am not into all the details myself. But feel free to merge it back into the main project.

@SebastianMetzger

Copy link
Copy Markdown

On second glance we probably just pulled in recent changes from the main repo at some point

@ikosta

ikosta commented Apr 26, 2023

Copy link
Copy Markdown
Author

On second glance we probably just pulled in recent changes from the main repo at some point

So this works good for you? Then I would push this PR further. Any concerns @SebastianMetzger?

@SebastianMetzger

SebastianMetzger commented Apr 27, 2023 via email

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants