Home > Mobile >  Electron store data locally without localstorage
Electron store data locally without localstorage

Time:04-27

Hi, i have a electron app builded using JavaScript.

I need to store some data and still after close the app.

I have find many ways, like json, localstorage.

I can't edit json using JavaScript only, i need a server, but my app is locally and i have many computers, and i can't host a localserver for each version of app

I found localstorage but when i change the destination of the app. It delete all data and it's danger, any problem in the electorn, all data deleted.

So I need to store data in electron locally and read/write data using javascript.

I think with server-side. I can read/write but i need a localhost, and my electorn app just a client-side program like browser.

All my solutions have a problem. I need database read/write client side and not localstorage.

I search on internet along but i can't found anything.

Sorry for my bad english :)

CodePudding user response:

Apparently there is no built-in way to do this apart from using localstorage.

If it is okay for you to use a third-party-module and save your data in an unencrypted json-file you could use the electron-store module.

According to their documentation there is a simple CRUD-API. This is an example from their github-readme:

const Store = require('electron-store');

const store = new Store();

store.set('unicorn', '           
  • Related