Premium Economy Software

Perth W Australia

Loki JS Quick Tutorial

January 22, 2017 Coding 0 comments

Loki JS is a lightweight Javscript based no sql database that you can use in your hybrid apps.

This week I messed around a bit, but I was upset that the documentation pretty much sucked, so I wrote some for you.


1. Installing

Use the Node Package Manager (NPM)

npm install lokijs

2. Setup with Browsify

So that you can run it in browser. Put this in your main.js file.

var loki = require('lokijs')
var db = new loki('loki.json')



3. Create your database (collection)

var namesDB = db.addCollection('names')


4. Next Add a Row. For say a names object 


5. Get that Row.

Lokijs automatically gives your row a unique ID called $loki

var namesObj = exerciseDB.get(exerciseID)

6. Update that Row = 'John Woo'


6a. Remove




7. Running a Where query

results = namesDB.where(function(obj) {
    return == 'John Woo';

//Add functionality 



8. Display All Rows (for debugging)

var namesFull =;