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

@brightchain/db

v0.23.25

Published

MongoDB-like document database driver backed by BrightChain block store

Downloads

960

Readme

@brightchain/db

A MongoDB-like document database driver backed by BrightChain's block store.

Overview

brightchain-db provides a familiar MongoDB-style API for storing and querying structured documents on top of BrightChain's Owner-Free block storage system. It supports:

  • Collections & Documentsdb.collection('users') returns a collection handle
  • CRUD operationsinsertOne, insertMany, findOne, find, updateOne, updateMany, deleteOne, deleteMany, replaceOne
  • Rich query operators$eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $regex, $exists, $and, $or, $not, $nor, $elemMatch
  • Projection & sorting – field selection, multi-field sort
  • Indexes – unique, compound, and single-field indexes for fast lookups
  • Transactions – multi-document ACID-like transactions with commit/abort
  • Aggregation pipeline$match, $group, $sort, $limit, $skip, $project, $unwind, $count, $addFields, $lookup
  • Cursor API – lazy iteration with skip, limit, sort, toArray
  • Express middleware – drop-in router for REST access to collections
  • Change streams – subscribe to insert/update/delete events

Quick Start

import { BrightChainDb } from '@brightchain/brightchain-db';
import { MemoryBlockStoreAdapter } from '@brightchain/brightchain-lib';
import { BlockSize } from '@brightchain/brightchain-lib';

// Create or connect to a block store
const blockStore = new MemoryBlockStoreAdapter({ blockSize: BlockSize.Medium });

// Open a database
const db = new BrightChainDb(blockStore);

// Get a collection
const users = db.collection('users');

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

// Query
const alice = await users.findOne({ name: 'Alice' });

// Rich queries
const adults = await users.find({ age: { $gte: 18 } }).sort({ name: 1 }).toArray();

// Indexes
await users.createIndex({ email: 1 }, { unique: true });

// Transactions
const session = db.startSession();
session.startTransaction();
try {
  await users.insertOne({ name: 'Bob', email: '[email protected]' }, { session });
  await users.updateOne({ name: 'Alice' }, { $set: { friend: 'Bob' } }, { session });
  await session.commitTransaction();
} catch (err) {
  await session.abortTransaction();
}

// Express middleware
import { createDbRouter } from '@brightchain/brightchain-db';
app.use('/api/db', createDbRouter(db));

Architecture

Documents are serialised to JSON and stored as blocks in the BrightChain block store. Each collection maintains an in-memory index that maps logical document IDs to content-addressable block checksums. The index itself is persisted as a block and tracked via a head registry.

Indexes are maintained as B-tree-like structures in memory, rebuilt from stored index metadata blocks on startup, and persisted after mutations.

Transactions use optimistic concurrency: writes are buffered in a journal and applied atomically on commit, with automatic rollback on abort.

License

MIT