Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save user data in electron.js app?

I seek to save user data for my electron.js app. The app has a graph with adjustable values, which disappear when relaunching the app. Demo: https://puu.sh/Bx5Or/ffb0382d0c.gif

How do I preserve these values? Can (and should) it be done with SQL?

like image 417
OverLordGoldDragon Avatar asked Mar 06 '23 09:03

OverLordGoldDragon


1 Answers

You have a lot of modules to store data in an Electron app :

  • http://lokijs.org
  • https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
  • https://github.com/agershun/alasql
  • https://github.com/amark/gun
  • https://github.com/google/leveldb
  • https://github.com/google/lovefield
  • https://github.com/jakearchibald/idb
  • https://github.com/jakearchibald/idb-keyval
  • https://github.com/sql-js/sql.js
  • https://github.com/localForage/localForage
  • https://github.com/louischatriot/nedb
  • https://github.com/pouchdb/pouchdb
  • https://github.com/pubkey/rxdb
  • https://github.com/typicode/lowdb
  • https://github.com/w3c/IndexedDB
  • https://github.com/yathit/ydn-db
  • https://github.com/TomPrograms/stormdb

I would suggest nedb which is pure JS and cross platform compatible. The simplest is localStorage, which is browser native. Or more simply, you can read/write data in a JSON file.

So, in your case, when the values are changed, save the data. On start, get them from the database and put them in your adjustable values.

like image 189
JeffProd Avatar answered Mar 11 '23 11:03

JeffProd