Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] cordova-electron support #960

Draft
wants to merge 15 commits into
base: dev
Choose a base branch
from
Draft

[Feature] cordova-electron support #960

wants to merge 15 commits into from

Conversation

ikosta
Copy link

@ikosta ikosta commented Nov 19, 2020

[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 [email protected] (it must be in the dependencies not devDependencies)
    cordova platform add [email protected] --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.

@brodycj
Copy link

brodycj commented Nov 20, 2020

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

Any updates on the progress of this PR?

@pjoriginal
Copy link

Any progress on this?

@ikosta
Copy link
Author

ikosta commented Apr 23, 2023

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

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

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

@ikosta
Copy link
Author

ikosta commented Apr 26, 2023

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
Copy link

SebastianMetzger commented Apr 27, 2023 via email

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