I'm about to choose a suitable local database for my offline ElectronJS application. The Desktop App must add/update/delete/retrieve data from JSON files locally. the database structure is as follows :
{
'data':[
{
'day':1344546000,
'transactions':[
{'time':'blabla', 'value1':'100',...},
{'time':'blabla', 'value1':'100',...},
{'time':'blabla', 'value1':'100',...},
]
},
{
'day':1344546000,
'transactions':[
{'time':'blabla', 'value1':'100',...},
{'time':'blabla', 'value1':'100',...},
{'time':'blabla', 'value1':'100',...},
]
},
....
]
}
This data must be placed locally in json file/files, so if the user closed the app and open it again the data should be retrieved.
each day
object will have less than 500 transactions a day
NEDB is a mongo API compatible, file-based database. It's a great fit for electron apps. In this post, I'll walk through my NEDB setup. It's fairly simple and is being used in production at HTTPSLocalhost app.
Absolutely. Just like a webpage can be offline .... it's all local files that make your app. Esp, for Electron, you are building a 'desktop app' that doesn't necessarily require anything external, although it can be a 'web app' of course.
The data is saved in a JSON file named config. json in app. getPath('userData') . You can use this module directly in both the main and renderer process.
With an improved runtime and great integration with JavaScript and Node. js, Electron JS makes both designing desktop apps and maintaining them on cross platforms easier and better.
The framework is designed to create desktop applications using web technologies (mainly HTML, CSS, and JavaScript, though other technologies such as frontend frameworks and Web Assembly are possible) which are rendered using a flavor of the Chromium browser engine, and a backend using the Node. js runtime environment.
As an example architecture, we'll use a desktop app for the Telegram chat web app. Electron will act as a wrapper for the existing web app without requiring any changes to the backend. Setting up Electron is easy for this type of app! There are no changes needed at the web app codebase level.
I would go for PouchDB: https://github.com/pouchdb/pouchdb
PouchDB was created to help web developers build applications that work as well offline as they do online.
NeDB looks also very promising: https://github.com/louischatriot/nedb
Embedded persistent or in memory database for Node.js, nw.js, Electron and browsers, 100% JavaScript, no binary dependency. API is a subset of MongoDB's and it's plenty fast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With