New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ledb

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ledb

LEDB interface for NodeJS

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

LEDB interface for NodeJS

License: MIT npm version npm downloads Travis-CI Build Status Appveyor Build status

The LEDB is an attempt to implement simple but efficient, lightweight but powerful document storage.

The abbreviation LEDB may be treated as an Lightweight Embedded DB, also Low End DB, also Literium Engine DB, also LitE DB, and so on.

Features

  • Processing JSON documents
  • Identifying documents using auto-incrementing integer primary keys.
  • Indexing fields of documents using unique or duplicated indexes.
  • Searching and ordering documents using indexed fields or primary key.
  • Selecting documents using complex filters with fields comparing and logical operations.
  • Updating documents using rich set of modifiers.
  • Storing documents into independent storages so called collections.
  • Flexible JSON query filters similar to a MongoDB.
  • The LMDB as backend for document storage and indexing engine.

Installation

Until pre-compiled binaries is missing you need Rust build environment for building native module.

Use latest stable Rust compiler. You can install it using rustup or packages in your system.

Usage example

import { Storage } from 'ledb';

// Open storage
const storage = new Storage("test_db/storage");
// It allows open storage with same path multiple times

// Get storage info
console.log("Storage info:", storage.get_info());
console.log("Storage stats:", storage.get_stats());

// Get collection handle
const posts = storage.collection("post");

// Insert document
let doc_id = posts.insert({title: "Foo", tag: ["Bar", "Baz"], timestamp: 1234567890);

// Get document by id
let doc = posts.get(doc_id);
console.log("Inserted document: ", doc);

// Put new version of document
posts.put(doc);

// Delete document by id
posts.delete(doc_id);

// Ensure indexes
posts.ensure_index("title", "unique", "string")
posts.ensure_index("tag", "index", "string")

// Get indexes
console.log("Indexes of post:", posts.get_indexes())

// Find all documents
let docs = posts.find(null);

// Find all documents with descending ordering
let docs = posts.find(null, "$desc");

// Find all documents with ascending ordering using field
let docs = posts.find(null, { timestamp: "$asc" });

// Find documents using filter
let docs = posts.find({ title: { $eq:"Foo" } });
let docs = posts.find({ $not: { title: { $eq: "Foo" } } });
let docs = posts.find({ $and: [ { timestamp: { $gt: 123456789 } } ,
                                { tag: { $eq: "Bar" } } ] },
                      { timestamp: "$desc" });
let docs = posts.find({ $or: [ { title: { $eq: "Foo" } } ,
                               { title: { $eq: "Bar" } } ] });

// Number of found documents
console.log("Found docs:", docs.count())

// Get documents one by one
for (let doc; doc = docs.next(); ) {
    console.log("Found doc:", doc);
}

// Skip N documents
docs.skip(3);

// Take N documents only
docs.take(5);

// Get all documents as an array
console.log("Found documents:", docs.collect());

// Update all documents
posts.update(null, { timestamp: { $set: 0 } });

// Update documents using filter
posts.update({ timestamp: { $le: 123456789 } }, { timestamp: { $set: 0 } });

// Remove all documents
posts.remove(null);

// Remove documents using filter
posts.remove({ timestamp: { $le: 123456789 } });

See also ledb.d.ts.

FAQs

Package last updated on 11 Jun 2020

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