LokiJS: in-memory NoSQL datastore for Cordova apps

LokiJS is a lightweight JavaScript in-memory database made by Techfort that provides a document-oriented alternative to the already well known SQLite. For many applications a NoSQL approach could be more preferable than relational data when working with complex object stores. LokiJS gives us the chance to do this in a very efficient way.

LokiJS is intended to be used as an in-memory database with the possibility of persisting the data. It is compatible with Node.js (filesystem) and browsers, which means that it can be also used in our hybrid mobile Cordova apps (localStorage and indexedDB).

A block of code is worth a thousand words:

Furthermore, LokiJS supports field indexing for faster document access and provides a built-in DynamicView class that also enables to use indexes on data subsets for even faster performance. DynamicViews work as queries that are recomputed in the background when data changes, so once a view is created you never have to worry about recalling or refreshing data, it is always updated and available.

It is also available for AngularJS through the lokijs module:

Its low footprint and high performance, along with a bunch of other features, make it worth giving a try! You can follow its Github repo here and learn more about it here. We hope you find this tool useful for your future hybrid apps!

Originally published at onsen.io on July 8, 2015.