LokiJS – the NoSQL database for your app

05.11.2016 Data store 0 Comments

Often we need to save data in the app or to persist data somehow, while the device is offline. I don’t believe it is a good idea to relay on such unstable HTML5 “standards” such as IndexDB or WebDB. Certainly one could use SQLite and there is a Cordova plugin already, but I found something different, something more useful. In most cases, mobile apps consuming data from RESTful web services, exchanging data in JSON format. Why you want to put this data into an SQL schema? Wouldn’t it be more natural to save it (and use it) as an object literal? How about searching for documents by nested properties? Or updating nested documents? NoSQL is your friend. Especially if you already have some experience with MongoDB, you already know how convenient it will be.

LokiJS is an in-memory, NoSQL database, which also provides a persistent storage functionality. It is not a Cordova plugin, it is a stand alone library. You can use it directly by including a JS file in your project or you can take advantage of the provided Angular Service. On their home page, there is a nice Quick Start guide. The project comes with nice and clean documentation, which also provides tutorials and query examples. If you are familiar with MongoDB, you’ll find almost full compatibility with its API.

Submit a comment