Reputation: 1091
I'm building portable node js server using electron. I'm using SQLITE database for storing data.
In development mode I put database file test.db
in directory where is my Main.js
file and everything is running perfectly.
When I deploy my app electron-builder --mac
and run it, it cannot access to database file. (File not found)
So my question is where should I store my test.db
file so it's working both in development and production mode?
Is it possible to embed db file somewhere while creating application for win/mac/linux so end user doesn't need to take care where is db file located?
Thank you
Upvotes: 5
Views: 5048
Reputation: 275
you can store it into application data,
const dbPath = path.join(app.getPath("userData"), "sample.db")
Check out docs here, https://www.electronjs.org/docs/api/app#appgetpathname
Upvotes: 5