Lokijs

3.
WHY?
● In-memory is faster than I/O
● SQLite is great but there is no NoSQL / document-oriented equivalent of it
● SQLite is cumbersome in a mobile / embedded context (who can be bothered
with SQL in a mobile app?)
● Phonegap and Node-Webkit apps would benefit from a javascript database where
data is plain javascript objects, and persisted on disk as JSON.
● Traditional databases rely on platform libraries which impose portability contraints
and version conflicts. Data is frequently 'locked-in'
● For many applications NoSql is a far more preferable and better performing
approach than relational data when working with complex object stores which are
built for consumption.

4.
Enter Loki
●
LokiJS is compatible with browser and node.js
●
Persistence to disk on inserts/updates/deletes (in node.js, node-webkit and cordova
environments)
●
Available on bower and npm
●
Extremely low footprint - 28KB uncompressed!!
●
Supports indexing, and uses Binary Search for search granting fast performance
●
NoSQL jargon: documents, collections, map, reduce
●
Compatibility: dependency free, native, pure javascript runs across many js environments
●
Portablility : entire database state can be serialized as a single entity to be restored in an
identical state or transferred across environments as a single JSON entity.
●
Performs better than similar products (NeDB, TaffyDB, PouchDB etc.), and it's much smaller

9.
Querying (Javascript views)
● Means of specifying complex 'edge case' query filters
● Write your own javascript filter function which can be
anonymous or persisted with a name as a view.
● Has access to the entire (possibly hierarchical) document
object
● Used for chained queries and dynamic views
● Worse performance / cant be serialized (need to be
reattach to dynview on load)

12.
Persistence
● Loki now supports three primary persistence methods : filesystem
(Node), localStorage (cordova/browser), and indexedDB
(cordova/browser)
● A new persistence adapter interface allows for interoperability with
other popular and/or custom data stores. Community members can
develop and submit adapters for popular datastores and submit a pull
request to share them.
● Autosave/Autoload capabilities exist for you to optionally utilize for
automating and bootstrapping persistence.

13.
IndexedDB Support for browsers
● Loki now implements an indexedDB App/Key/Value Catalog,
implemented using the new persistence adapter interface.
● This catalog can contain as many databases as your storage
quota allows, organized by application. This allows grouping,
listing and querying the catalog of databases by 'application'
groups.
● Loki's indexedDB adapter supports console use for easily
managing your catalog from a browser console.