Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lokijs

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lokijs

Fast document oriented javascript in-memory database

  • 1.3.17
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
570K
increased by13.17%
Maintainers
1
Weekly downloads
 
Created

What is lokijs?

LokiJS is an in-memory database that prioritizes performance and simplicity. It is written in JavaScript and can be used in web browsers, Node.js, and Cordova/PhoneGap applications. It offers a powerful query system and supports indexing for fast lookups.

What are lokijs's main functionalities?

In-memory database

LokiJS allows you to create an in-memory database, add collections, and insert documents.

const loki = require('lokijs');
const db = new loki('example.db');
const users = db.addCollection('users');
users.insert({ name: 'Odin', age: 1000 });
users.insert({ name: 'Thor', age: 30 });

Powerful query system

You can query the database using a MongoDB-like query syntax to retrieve data based on complex criteria.

const elderlyGods = users.find({ age: { '$gt': 500 } });

Indexing for fast lookups

LokiJS supports indexing of collections to enable faster query response times, especially beneficial for large datasets.

users.ensureIndex('age');
const youngGods = users.find({ age: { '$lte': 100 } });

Persistence adapters

LokiJS can be configured to use various persistence adapters, allowing you to save the database state to a file, local storage, or other storage systems.

const lokiFsAdapter = require('lokijs/src/loki-fs-structured-adapter');
const adapter = new lokiFsAdapter();
const db = new loki('example.db', { adapter: adapter });

Changes API

The Changes API allows you to listen for changes in the database, which can be used for syncing with a remote database or triggering other actions.

db.on('changes', function(changes) {
  console.log('Database changes:', changes);
});
users.insert({ name: 'Loki', age: 1042 });

Other packages similar to lokijs

Keywords

FAQs

Package last updated on 19 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc