SlideShare a Scribd company logo
1 of 16
LokiJS
Javascript In-Memory Database
@tech_fort
??? WHAT ???
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.
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
Sample Usage
var loki = require('lokijs'),
  db = new loki('demo.json'),
  doctors;
doctors = db.addCollection('doctors', { indices: 
['name']});
doctors.insert({ name: 'David Tennant', doctor: 
10});
doctors.insert({ name: 'Matt Smith', doctor: 11});
doctors.insert({ name: 'Peter Capaldi', doctor: 
12});
Updates
● Updates are optional. LokiJS holds references
to objects so there's no need to update an
object. However, update(obj) can be called to
force re-indexing of collections.
Querying
● Querying is quite intuitive:
doctors.get(index);
doctors.find({ doctors: 10}); 
doctors.find({ doctors: { '$gte' : 
9}});
Querying (Mongo Style)
Mongo style queries will benefit from access to
index optimizations.
● Declarative query definition via a query object
● Current supported operators include $eq, $gt,
$gte, $lt, $lte, $ne, $regex, $in, $contains
● Supports dot notation for deep querying
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)
Fluent API
You can resort to functions to obtain your data by
leveraging the built-in ResultSet class:
doctors.chain()
  .find({ doctor: { '$gte': 9 }})
  .where(function (obj) { return 
obj.name.indexOf(“t”) != ­1; })
  .simplesort(“name”)
  .data(); // this exposes the data
Dynamic Views
Views hold references to filtered data to optmize search even further
(avoiding to scan the entire collection).
Thet maintain freshness of query results optimally as they are notified of
data inserts, updates and deletes.
var view = doctors.addDynamicView(“latestDoctors”);
view.applyFind({ doctor: { '$gte': 8}});
view.applySort(function (a, b) {
  return a.doctor < b.doctor;
});
// inspect the data
console.log(view.data());
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.
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.
Summary
● Use collection operations (insert, update, delete)
for document-oriented maintenance
● Use collection operations (find, where) for optimal
query performance
● Use resultset with fluent-like syntax for defining
complex query-oriented pipelines
● Use dynamic view for defining views which inherit
the resultset pipeline, yet avoid needing to requery
RoadMap
● MRU cache / Key-value store option
● TCP and HTTP Wrappers to enable running
LokiJS on dedicated (virtual) machines
● Replication
● Horizontal scaling
● MongoDB API subset compatibility
Links:
Web: http://lokijs.org
Github: https://github.com/techfort/LokiJS
Contributors:
Joe Minichino
Dave Easterday
@tech_fort

More Related Content

What's hot (20)

Hexadecimal to octal conversion
Hexadecimal to octal conversionHexadecimal to octal conversion
Hexadecimal to octal conversion
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Quick sort
Quick sortQuick sort
Quick sort
 
C bitwise operators
C bitwise operatorsC bitwise operators
C bitwise operators
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
 
Priority queues
Priority queuesPriority queues
Priority queues
 
Algorithm: priority queue
Algorithm: priority queueAlgorithm: priority queue
Algorithm: priority queue
 
Python programming : List and tuples
Python programming : List and tuplesPython programming : List and tuples
Python programming : List and tuples
 
Immutable vs mutable data types in python
Immutable vs mutable data types in pythonImmutable vs mutable data types in python
Immutable vs mutable data types in python
 
Binary addition and subtraction
Binary addition and subtractionBinary addition and subtraction
Binary addition and subtraction
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
EJB .
EJB .EJB .
EJB .
 
AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
10.m way search tree
10.m way search tree10.m way search tree
10.m way search tree
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]FUNCTIONS IN PYTHON[RANDOM FUNCTION]
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
 
1.2 sql create and drop table
1.2 sql create and drop table1.2 sql create and drop table
1.2 sql create and drop table
 
Insertion sort bubble sort selection sort
Insertion sort bubble sort  selection sortInsertion sort bubble sort  selection sort
Insertion sort bubble sort selection sort
 

Similar to Lokijs

Polyglot Database - Linuxcon North America 2016
Polyglot Database - Linuxcon North America 2016Polyglot Database - Linuxcon North America 2016
Polyglot Database - Linuxcon North America 2016Dave Stokes
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQLbalwinders
 
Elasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparisonElasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparisonjeetendra mandal
 
Couchbase - Introduction
Couchbase - IntroductionCouchbase - Introduction
Couchbase - IntroductionKnoldus Inc.
 
ArangoDB – A different approach to NoSQL
ArangoDB – A different approach to NoSQLArangoDB – A different approach to NoSQL
ArangoDB – A different approach to NoSQLArangoDB Database
 
Analysis on NoSQL: MongoDB Tool
Analysis on NoSQL: MongoDB ToolAnalysis on NoSQL: MongoDB Tool
Analysis on NoSQL: MongoDB Toolijtsrd
 
Mongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMohan Rathour
 
NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021Thodoris Bais
 
MongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data scienceMongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data sciencebitragowthamkumar1
 
Couchbase - Yet Another Introduction
Couchbase - Yet Another IntroductionCouchbase - Yet Another Introduction
Couchbase - Yet Another IntroductionKelum Senanayake
 
SQL vs MongoDB
SQL vs MongoDBSQL vs MongoDB
SQL vs MongoDBcalltutors
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBMarco Segato
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsWinston Hsieh
 
A Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - HabilelabsA Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - HabilelabsHabilelabs
 

Similar to Lokijs (20)

Polyglot Database - Linuxcon North America 2016
Polyglot Database - Linuxcon North America 2016Polyglot Database - Linuxcon North America 2016
Polyglot Database - Linuxcon North America 2016
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
CSCi226PPT1
CSCi226PPT1CSCi226PPT1
CSCi226PPT1
 
Elasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparisonElasticsearch vs MongoDB comparison
Elasticsearch vs MongoDB comparison
 
NoSql Databases
NoSql DatabasesNoSql Databases
NoSql Databases
 
Unit 3 MongDB
Unit 3 MongDBUnit 3 MongDB
Unit 3 MongDB
 
Couchbase - Introduction
Couchbase - IntroductionCouchbase - Introduction
Couchbase - Introduction
 
ArangoDB – A different approach to NoSQL
ArangoDB – A different approach to NoSQLArangoDB – A different approach to NoSQL
ArangoDB – A different approach to NoSQL
 
Analysis on NoSQL: MongoDB Tool
Analysis on NoSQL: MongoDB ToolAnalysis on NoSQL: MongoDB Tool
Analysis on NoSQL: MongoDB Tool
 
Mongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorial
 
NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021NoSQL Endgame LWJUG 2021
NoSQL Endgame LWJUG 2021
 
MongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data scienceMongoDB Lab Manual (1).pdf used in data science
MongoDB Lab Manual (1).pdf used in data science
 
Couchbase - Yet Another Introduction
Couchbase - Yet Another IntroductionCouchbase - Yet Another Introduction
Couchbase - Yet Another Introduction
 
Jooq java object oriented querying
Jooq java object oriented queryingJooq java object oriented querying
Jooq java object oriented querying
 
SQL vs MongoDB
SQL vs MongoDBSQL vs MongoDB
SQL vs MongoDB
 
No sq lv1_0
No sq lv1_0No sq lv1_0
No sq lv1_0
 
Oslo bekk2014
Oslo bekk2014Oslo bekk2014
Oslo bekk2014
 
SQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDBSQL vs NoSQL, an experiment with MongoDB
SQL vs NoSQL, an experiment with MongoDB
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
A Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - HabilelabsA Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - Habilelabs
 

Recently uploaded

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 

Recently uploaded (20)

AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

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
  • 6. Updates ● Updates are optional. LokiJS holds references to objects so there's no need to update an object. However, update(obj) can be called to force re-indexing of collections.
  • 7. Querying ● Querying is quite intuitive: doctors.get(index); doctors.find({ doctors: 10});  doctors.find({ doctors: { '$gte' :  9}});
  • 8. Querying (Mongo Style) Mongo style queries will benefit from access to index optimizations. ● Declarative query definition via a query object ● Current supported operators include $eq, $gt, $gte, $lt, $lte, $ne, $regex, $in, $contains ● Supports dot notation for deep querying
  • 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)
  • 10. Fluent API You can resort to functions to obtain your data by leveraging the built-in ResultSet class: doctors.chain()   .find({ doctor: { '$gte': 9 }})   .where(function (obj) { return  obj.name.indexOf(“t”) != ­1; })   .simplesort(“name”)   .data(); // this exposes the data
  • 11. Dynamic Views Views hold references to filtered data to optmize search even further (avoiding to scan the entire collection). Thet maintain freshness of query results optimally as they are notified of data inserts, updates and deletes. var view = doctors.addDynamicView(“latestDoctors”); view.applyFind({ doctor: { '$gte': 8}}); view.applySort(function (a, b) {   return a.doctor < b.doctor; }); // inspect the data console.log(view.data());
  • 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.
  • 14. Summary ● Use collection operations (insert, update, delete) for document-oriented maintenance ● Use collection operations (find, where) for optimal query performance ● Use resultset with fluent-like syntax for defining complex query-oriented pipelines ● Use dynamic view for defining views which inherit the resultset pipeline, yet avoid needing to requery
  • 15. RoadMap ● MRU cache / Key-value store option ● TCP and HTTP Wrappers to enable running LokiJS on dedicated (virtual) machines ● Replication ● Horizontal scaling ● MongoDB API subset compatibility