Lightweight javascript in-memory database: LokiJS

added by Robert Greyling
11/10/2014 2:26:33 PM

3439 Views

LokiJS is an in-memory database which prioritises performance over everything LokiJS supports field indexing for faster document access and performs really well (near 500,000 ops/s) on those. Its built-in DynamicView class also enables to utilize indexes on data subsets for even faster performance.


6 comments

Drew Peterson
11/10/2014 6:35:43 PM
I like the API, the chaining abilities remind me a lot of LINQ. The dynamic view concept is a nice addition. @tech_fort how would you compare developing an application using Loki vs Couchdb or something similar to that? Obviously Loki doesn't share a lot of the same concerns (ACID), but from the standpoint of comparing document databases with javascript API's, how do they match up?

Robert Greyling
11/10/2014 6:56:18 PM
I'm interested in this from an "offline app" perspective gathering up data to push later when app resync with backend services or other data stores. @tech_fort have you used LokiJS in conjunction with other backend data stores in thise kind of scenario and how easy do the document types marry up between them. Hopefully the question is clear enough - basically looking for a hybrid type solution at the moment. Thanks! Rob

techfort
11/10/2014 7:33:05 PM
@drewpcodes Couchdb was a big influence for the concept of dynamic view. I honestly feel that our indexing system in conjunction with the self-updating dynamicview are what makes LokiJS a unique product at the moment. Purely from a JS enthusiast perspective, another cool feature is the ability to get LokiJS with an npm install (i only wish i could do npm install mongodb...) naturally because there's no external dependency on a 3rd party application/lib. Performance has only been benchmarked so far against similar products (NeDB, PouchDB, TaffyDB etc.) and so far LokiJS has obtained stellar results - with orders of magnitude faster than other products on find operations and inserts. Let me know if there is any aspect in particular you are trying to benchmark and I'll try to answer to the best of my knowledge. @RobertTheGrey : just before releasing v1.0 i got a similar request so we rolled out our own EventEmitter class, which means all db operations emit and event and you can assign handlers to those, including (in a browser environment) storing to localStorage or serializing the db to send it over to some backend service. On the to-do for v1.1 (due in december) is possibly incremental/differential datasets, so you can send patches to the backend rather than the entire db. Hope this helps! Joe

Robert Greyling
11/11/2014 9:59:15 AM
Hey Joe - sounds great! The patching side is something we'd be especially interested in long term, but pushing to localStorage and then building our own patch from that seems quite feasible as a first stab. The `EventEmmitter` sounds awesome since we're running a CQRS setup which consumes events from queues anyway so maybe not too much work for a POC it seems. Thanks for the feedback and for LokiJS! All the best Rob

Andrew Robbins
11/12/2014 3:29:04 AM
This sounds so awesome. I haven't had time to try it out yet but I'm excited to give it a run.

Bob Senoff
11/12/2014 4:53:51 PM
@ceejbot " Purely from a JS enthusiast perspective, another cool feature is the ability to get LokiJS with an npm install (i only wish i could do npm install mongodb...) naturally because there's no external dependency on a 3rd party application/lib." Any thoughts on this?