5

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?

markalex
  • 8,623
  • 2
  • 7
  • 32
mesqueeb
  • 5,277
  • 5
  • 44
  • 77
  • In memory means not persisted to disk. that means it only lasts as long as it is loaded. – Josh Mar 19 '19 at 06:38
  • @Josh that's weird, if "in-memory" means "not persisted" what does "in-memory with persistence" mean? o_O Based on your information I would feel like they are contradicting themselves...? Or am I wrong. – mesqueeb Mar 19 '19 at 07:09
  • 3
    @Josh (and mesqueeb) in-memory means that the entire data is loaded in memory and queried from memory. Persistence to disk actually unrelated. LokiJS provides persistence which enables you to resume state across sessions or in case of error/crash. Traditional databases save data to disk and query the files to return data (they use memory for some level of query caching). LokiJS's value is in the way you can query data but it can use indexedDB as a persistence mechanism. – Joe Minichino Mar 19 '19 at 13:47
  • @JoeMinichino thanks so much for your comment!! I didn't expect to see you around here . I really appreciate what you did with LokiJS. – mesqueeb Mar 19 '19 at 23:25
  • @mesqueeb thanks! good luck with your work! – Joe Minichino Mar 20 '19 at 13:32

2 Answers2

5

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-

floer32
  • 2,190
  • 4
  • 29
  • 50
Ali Khalid
  • 1,345
  • 8
  • 19
0

you can check also PouchDB
https://github.com/pouchdb/pouchdb

which has double stars & forks than Locki.js and seems to do the same.

ofir_aghai
  • 3,017
  • 1
  • 37
  • 43