Skip to content
Mikael Carlsson edited this page May 18, 2019 · 5 revisions

To use lociDB in your NodeJS application you need to first Install it. Then you require it in your code and create an instance of it.

From version 0.2.2 you can decide where you want to save the lociDB database folder and what name it should have.

const lociDB = require("locidb");
const loci = new lociDB();

By default this saves lociDB database folder in users appData folder with the name locidb.

Linux:

"/home/username/.config"

Mac:

"/Users/username/Library/Application Support"

Windows:

"C:\Users\username\AppData\Roaming"

To change destination and name

const lociDB = require("locidb");
const loci = new lociDB('/path/to/destination', 'mycooldb');

To keep default destination but change name

const lociDB = require("locidb");
const loci = new lociDB(undefined, 'mycooldb');

If you are using lociDB in an electron app it's recommended to use app.getPath('userData') as destination.

const lociDB = require("locidb");
const loci = new lociDB(app.getPath('userData'), 'mycooldb');

You can now access all the functions like this

loci.get("string");
loci.set("string", object);
etc.