cordovaindexeddbin-memorylokijs

in-memory DB (lokiJS) vs regular indexedDB


I was looking for a wrapper library for indexedDB that can store data.

(Specific use is for a JavaScript cordova app but one that can also work in the browser)

I have found LokiJS which seems feasible. However, LokiJS says it's an:

In-memory JavaScript Datastore with Persistence

But I don't understand what "in-memory" means. I tried googling, looking around, but couldn't find a concise explanation...

How is "in-memory" indexedDB different from regular indexedDB?


Solution

  • LokiJS is a in-memory DB, which means it will allow you to load, query etc all your data in-memory. Since it is written in Javascript, it will work on multiple environments, inside your browser, inside a NodeJS application, inside a Cordova app etc.

    If you are using this inside a Browser application, it can use localstorage or indexedDB to store the data.

    If you are using this inside a NodeJS application, it can use the file system or another DB (MySQL, mssql, etc) to store the data.

    If you are using this inside a Cordova application, it can use SQLite to store the data.

    Basically, depending on where are you running your application and what storage options are available on that platform, it will use that to persist the data.

    You can look here to see different adapters available to store data on different platforms-