LokiJS allows you to save the database that you use as the JSON file, as you can see from the save function docs:
Saves db according to persistence adapter specified in Loki constructor. If nothing is specified, Loki tries to default methods (fs in Node, localStorage in the browser and cordova).
This means that by default, localStorage is used in a cord that will already be stored on the file system.
Then you can use the Loki load() function to load a specific database name.
Note that this is not explicitly required , you can simply create a new database in Loki:
var db = new loki('db_name.json', { autosave: true, autosaveInterval: 60 * 1000,
If you specify the autoload and autosave , you donβt need to process anything yourself, so the data will be saved automatically using localStorage on the cord.
In addition, if you want to do something differently, that is, not to use localStorage, you can create your own adapter for saving to the file system or even to the server or cloud storage . This requires you, of course, to write an Adapter, you can see an example in Loki gitHub here (this is an example of a jQuery AJAX adapter)
EDIT: As @Joe Minichino noted, there is a ready-made Cordova FS adapter for Loki , it should work right out of the box, check it out!