Open deckyfx opened 2 years ago
I was trying to answer the same question and figured out how to make an IPC channel to relay the sql commands and replies back and forth between the main process and the renderer process. To do this I made a function called asyncSql that I put in src/renderer/index.tsx. I also made another ipcMain module with IPC listener in main.ts (not sure if I'm naming this correctly -- look for "asynchronous-sql-command" and "asynchronous-sql-reply"). Then I used asyncSql to submit the user-supplied sql query and process the response (see this page as an example).
I made it into a new template electron-react-boilerplate-sqlite3 and spell out all the steps I went through in my README. I also address an issue with the database maybe (not sure) being in the wrong place when the app is packaged. It's my first time doing a lot of these steps, not sure what mistakes I might have made. But it seems to work for me so far so I hope it's helpful for you!
The logic is fine for Data base connections. I am using fabric native deps. Data' such as string, obj, array are passed through IPC. but Node modules not passing. How can i import fabric in render. I followed these https://electron-react-boilerplate.js.org/docs/native-modules Err: fabric undefined err in renderer
Summary
Now that I manage to install NativeModules and used it in main.ts, how to expose it into the renderers script?