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

lmcs-db

v2.0.1

Published

Lightweight Modular Collection Storage - Secure & Transactional

Readme

LMCS-DB v2.0

TypeScript Node License

Lightweight Modular Collection Storage — A high-performance, file-based NoSQL database for Node.js with multiple storage engines, ACID transactions, and military-grade encryption.

✨ Features

  • 🗄️ Multiple Storage Engines: Memory, JSON, Binary, and Append-Only Log (AOL)
  • 🔐 Built-in Encryption: AES-256-GCM with PBKDF2 key derivation
  • 🔄 ACID Transactions: Multi-document transactions with rollback support
  • ⚡ High Performance: In-memory indexes, streaming queries, and batch operations
  • 🔍 Advanced Queries: MongoDB-like operators ($gt, $lt, $or, $and, $in)
  • 📦 Zero Dependencies: Lightweight with minimal footprint
  • 🧪 Full TypeScript: Type-safe collections with IntelliSense support

🚀 Quick Start

npm install lmcs-db
import { Database } from "lmcs-db";

interface User {
  _id?: string;
  name: string;
  email: string;
  age: number;
}

// Create database
const db = await Database.create({
  storageType: "binary",
  databaseName: "myapp",
  encryptionKey: "your-secret-key-32-chars!!", // Optional
});

const users = db.collection<User>("users");

// Insert
await users.insert({ name: "Alice", email: "[email protected]", age: 30 });

// Query
const adults = await users.findAll({
  filter: { age: { $gte: 18 } },
  sort: { name: 1 },
  limit: 10,
});

// Transaction
await db.transaction(async (trx) => {
  await trx.insert("users", { name: "Bob", age: 25 });
  await trx.update("users", "alice-id", { age: 31 });
});

💾 Storage Engines | Engine | Persistence | Speed | Use Case | Compression | | ---------- | ----------- | ------------- | ------------------------------------- | -------------- | | Memory | ❌ Volatile | ⚡ Ultra-fast | Cache, testing, temporary data | N/A | | JSON | ✅ File | 🐢 Moderate | Config files, small datasets (<10MB) | None (text) | | Binary | ✅ File | 🚀 Fast | General purpose, medium datasets | Binary packing | | AOL | ✅ File | ⚡ Fast writes | Logs, event sourcing, high throughput | Compaction |

Engine Details

Memory Storage

const db = await createDatabase({
  storageType: "memory",
  databaseName: "cache",
});
// Data lost on process exit. Fastest option.

JSON Storage

const db = await createDatabase({
  storageType: "json",
  databaseName: "config",
});
// Human-readable, but slower than binary.

Binary Storage

const db = await createDatabase({
  storageType: "binary",
  databaseName: "data",
  encryptionKey: "secret", // Optional encryption
});
// Compact binary format with CRC32 checksums

AOL (Append-Only Log)

const db = await Database.create({
  storageType: "aol",
  databaseName: "events",
  bufferSize: 1000, // Buffer before fsync
  compactionInterval: 60000, // Automatic cleanup every 60s
});
// O(1) writes, perfect for event sourcing

🔍 Query API

Basic Queries

// Find one
const user = await users.findOne({ email: "[email protected]" });

// Find all
const all = await users.findAll();

// Count
const total = await users.count();

Advanced Filtering

// Comparison operators
const adults = await users.findAll({ filter: { age: { $gte: 18 } } });
const rich = await users.findAll({ filter: { salary: { $gt: 100000 } } });

// Logical operators
const result = await users.findAll({
  filter: {
    $or: [{ age: { $lt: 18 } }, { vip: true }],
  },
});

// Array operators (if field is array)
const tagged = await posts.findAll({
  filter: { tags: { $in: ["typescript", "nodejs"] } },
});

Sorting and Pagination

const page = await users.findAll({
  filter: { active: true },
  sort: { createdAt: -1 }, // -1 = descending, 1 = ascending
  skip: 20, // Offset
  limit: 10, // Page size
});

Streaming (Memory Efficient)

// Process millions of records without loading into memory
const stream = logs.findStream({ filter: { level: "error" } });

for await (const error of stream) {
  await sendAlert(error);
}

🔄 Transactions ACID transactions ensure data consistency across multiple operations:

await db.transaction(async (trx) => {
  // All operations succeed or all rollback
  const order = await trx.insert("orders", { total: 100, status: "pending" });
  await trx.insert("order_items", { orderId: order._id, product: "Laptop" });
  await trx.update("inventory", "laptop-123", { stock: { $dec: 1 } });

  if (somethingWrong) {
    throw new Error("Rollback everything");
  }
});

🔐 Security Encryption Algorithm: AES-256-GCM Key Derivation: PBKDF2 with 100,000 iterations Unique IV per encryption operation Authentication tag prevents tampering

const db = await Database.create({
  storageType: "binary",
  databaseName: "secrets",
  encryptionKey: process.env.DB_KEY, // Load from secure source
});

// All data transparently encrypted on disk
await secrets.insert({ password: "super-secret" });

Indexing Create indexes for fast queries:

// Single field
users.createIndex("email", { unique: true });

// Compound
orders.createIndex(["userId", "createdAt"]);

// Sparse (skip null values)
users.createIndex("phone", { sparse: true });

📊 Performance Tips

  1. Use Memory storage for unit tests (10x faster)
  2. Batch inserts instead of individual awaits
  3. Create indexes on frequently queried fields
  4. Use streaming for large datasets (>10k records)
  5. Compact AOL periodically to reclaim space
  6. Enable checksums for critical data integrity
// Batch insert (much faster)
await Promise.all(
  items.map(item => collection.insert(item))
);

// Compact AOL storage
await db.compact();

🧪 Testing

# Run all tests
npm test

# Run specific suite
npm test -- storage.test.ts

# With coverage
npm run test:coverage

📁 Project Structure

data/
├── myapp.bin        # Binary storage file
├── myapp.json       # JSON storage file
└── myapp.aol        # Append-only log

src/
├── core/
│   ├── database.ts      # Main database class
│   ├── collection.ts    # Collection operations
│   ├── transaction.ts   # ACID transactions
│   └── indexer.ts       # Index management
├── storage/
│   ├── base.ts          # Storage interface
│   ├── memory.ts        # In-memory storage
│   ├── json.ts          # JSON file storage
│   ├── binary.ts        # Binary storage
│   └── aol.ts           # Append-only log
└── crypto/
    └── manager.ts       # Encryption utilities

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. Open a Pull Request

📄 License MIT License - see LICENSE file.

Made with ❤️ by Leandro A. da Silva