npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@liorandb/core

v1.0.5

Published

LioranDB is a lightweight, local-first, peer-to-peer, file-based database with a MongoDB-style Node.js API and a simple CLI for seamless distributed development.

Readme

@liorandb/core

LioranDB Core Module – Lightweight, local-first, peer-to-peer database management for Node.js.

This is the core system-level module of LioranDB. It provides foundational database management functionality, including collections, queries, updates, encryption, and environment setup. Note: This is not the final database product, but a core module designed to be used in larger systems.


Table of Contents


Installation

npm install @liorandb/core

Node.js v18+ recommended.


Overview

@liorandb/core provides:

  • Local-first, file-based database directories.
  • MongoDB-style API (db, collection, insertOne, find, updateOne, etc.).
  • Peer-to-peer-friendly design.
  • Data encryption at rest.
  • Automatic environment configuration.
  • TypeScript typings for full developer support.

This module is intended for Node.js projects and can serve as the core database engine for larger LioranDB systems.


Getting Started

import { LioranManager } from "@liorandb/core";

async function main() {
  const manager = new LioranManager();
  const db = await manager.db("myDatabase");

  const users = db.collection("users");

  // Insert a document
  const user = await users.insertOne({ name: "Alice", age: 25 });

  // Query documents
  const results = await users.find({ age: { $gte: 18 } });

  console.log(results);
}

main();

API Reference

LioranManager

Manages databases and provides MongoDB-style client access.

class LioranManager {
  rootPath: string;
  db(name: string): Promise<LioranDB>;
  createDatabase(name: string): Promise<LioranDB>;
  openDatabase(name: string): Promise<LioranDB>;
  closeDatabase(name: string): Promise<void>;
  renameDatabase(oldName: string, newName: string): Promise<boolean>;
  deleteDatabase(name: string): Promise<boolean>;
  dropDatabase(name: string): Promise<boolean>;
  listDatabases(): Promise<string[]>;
}

Example:

const manager = new LioranManager();
await manager.createDatabase("testDB");
const db = await manager.db("testDB");

LioranDB

Represents a single database instance with multiple collections.

class LioranDB {
  basePath: string;
  dbName: string;
  collection<T>(name: string): Collection<T>;
  createCollection(name: string): Promise<boolean>;
  deleteCollection(name: string): Promise<boolean>;
  dropCollection(name: string): Promise<boolean>;
  renameCollection(oldName: string, newName: string): Promise<boolean>;
  listCollections(): Promise<string[]>;
}

Example:

const users = db.collection("users");
await db.createCollection("products");
const collections = await db.listCollections();

Collection

Handles documents within a database.

class Collection<T extends { _id?: string }> {
  insertOne(doc: T): Promise<T>;
  insertMany(docs: T[]): Promise<T[]>;
  find(query?: FilterQuery<T>): Promise<T[]>;
  findOne(query?: FilterQuery<T>): Promise<T | null>;
  updateOne(filter: FilterQuery<T>, update: UpdateQuery<T>, options?: { upsert?: boolean }): Promise<T | null>;
  updateMany(filter: FilterQuery<T>, update: UpdateQuery<T>): Promise<T[]>;
  deleteOne(filter: FilterQuery<T>): Promise<boolean>;
  deleteMany(filter: FilterQuery<T>): Promise<number>;
  countDocuments(filter?: FilterQuery<T>): Promise<number>;
  close(): Promise<void>;
}

Example:

await users.insertOne({ name: "Bob", age: 30 });
const adults = await users.find({ age: { $gte: 18 } });
await users.updateOne({ name: "Bob" }, { $inc: { age: 1 } });
await users.deleteOne({ name: "Alice" });

Query Operators

  • $gt, $gte, $lt, $lte, $ne, $eq, $in

Example:

users.find({ age: { $gte: 18, $lt: 65 } });

Update Operators

  • $set – set field values
  • $inc – increment numeric fields

Example:

users.updateOne({ name: "Alice" }, { $set: { city: "Mumbai" }, $inc: { age: 1 } });

Utilities

function getBaseDBFolder(): string;

Returns the root folder for LioranDB databases. Automatically sets environment variables if missing.


Encryption

All documents are encrypted using AES-256-GCM.

  • Uses a master key stored in .secureKey within the base folder.
  • Data is encrypted automatically before storage and decrypted on retrieval.

Utility Functions:

  • encryptData(obj)
  • decryptData(encStr)

Master Key Management:

  • Managed via getMasterKey()
  • Auto-generates 256-bit key if not found.

Environment Setup

  • getBaseDBFolder() ensures LIORANDB_PATH is set.
  • Auto-generates scripts for Windows PowerShell or Linux/macOS bash.
  • Guides users to set system-wide environment variables if missing.

License

Author: Swaraj Puppalwar License: LIORANDB LICENSE


Keywords: p2p-database, lioran, liorandb, p2p-db, peer-to-peer-db, peer-to-peer-database, localfirst-db, localfirst-database