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

@tomhundley/prismdb

v1.0.0

Published

Embedded document database for Node.js with Mongo-style queries, indexes, aggregations, transactions, and JSON persistence

Readme

@tomhundley/prismdb

An embedded document database for Node.js. Store JSON documents in collections, query them with Mongo-style operators, index fields, run aggregations, wrap writes in transactions, and persist to a JSON file.

Zero runtime dependencies. Node 18+.

Install

npm install @tomhundley/prismdb

Quick start

import { createDb } from "@tomhundley/prismdb";

const db = createDb({ name: "shop" });
const users = db.collection("users");

users.insertOne({ name: "Ada", age: 36, tags: ["math", "cs"] });
users.insertMany([
  { name: "Grace", age: 85, tags: ["navy"] },
  { name: "Alan", age: 41, tags: ["crypto"] },
]);

const found = users
  .find({ age: { $gte: 36 } })
  .sort({ name: 1 })
  .project({ name: 1, age: 1 })
  .toArray();

Queries

users.find({ name: "Ada" });
users.find({ age: { $gt: 30, $lt: 50 } });
users.find({ tags: { $in: ["math"] } });
users.find({ $or: [{ name: "Ada" }, { age: { $gte: 80 } }] });
users.find({ name: { $regex: "^A", $options: "i" } });
users.find({ $text: { $search: "crypto" } });

Operators: $eq $ne $gt $gte $lt $lte $in $nin $exists $regex $size $type $all $elemMatch $not $mod $and $or $nor $text.

Updates: $set $unset $inc $mul $min $max $push $pull $addToSet $rename $currentDate.

Indexes, schema, aggregation

users.createIndex("email", { unique: true, name: "email_unique" });

const orders = db.collection("orders");
orders.insertMany([
  { sku: "book", qty: 2, price: 10 },
  { sku: "book", qty: 1, price: 10 },
  { sku: "pen", qty: 5, price: 2 },
]);

const totals = orders.aggregate([
  { $unwind: "$qty" },
  { $group: { _id: "$sku", sold: { $sum: "$qty" }, avg: { $avg: "$price" } } },
  { $sort: { sold: -1 } },
]);

Schema on create:

const db = createDb({
  schemas: {
    users: {
      name: { type: "string", required: true },
      age: { type: "number", min: 0 },
      role: { type: "string", enum: ["admin", "user"] },
    },
  },
});

Transactions and persistence

db.transaction((tx) => {
  tx.collection("accounts").updateOne({ name: "Ada" }, { $inc: { balance: -20 } });
  tx.collection("accounts").updateOne({ name: "Grace" }, { $inc: { balance: 20 } });
});

import { saveToFile, loadFromFile } from "@tomhundley/prismdb";

await saveToFile(db, "./data/shop.json");
const restored = await loadFromFile("./data/shop.json");

If the transaction function throws, all collections roll back to the snapshot taken at the start.

Change feed

users.watch(({ type, documents }) => {
  console.log(type, documents.map((d) => d._id));
});

What it is for

Use PrismDB when you want a small local database inside a Node process: CLIs, tests, desktop tools, caches, prototypes — without running MongoDB or SQLite. It is not a networked server and not a replacement for Postgres at scale.

License

MIT