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

db-faker

v1.0.2

Published

A lightweight MongoDB-like local JSON database

Readme

db-faker

A lightweight, MongoDB-like local JSON database for Node.js and TypeScript applications.

db-faker lets you work with local collections using a simple API:

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

await users.insert({
  name: "John",
  age: 25
});

const usersList = (await users.find()).all();

Features

  • Local JSON-based storage
  • MongoDB-style collections
  • TypeScript support
  • Generic, type-safe collections
  • Automatic document IDs
  • Async CRUD API
  • Separate data for each collection
  • No external database server required

Installation

npm install db-faker

Usage

import { DB } from "db-faker";

interface User {
  name: string;
  age: number;
}

const db = new DB("database");

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

await users.insert({
  name: "John",
  age: 25
});

const result = (await users.find()).first();

console.log(result);

Collections

Create or access a collection using db.collection():

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

const products = await db.collection<Product>("products");

Each collection maintains its own documents.

Insert

await users.insert({
  name: "John",
  age: 25
});

A document ID can be generated automatically.

Example stored document:

{
  "name": "John",
  "age": 25,
  "id": "users__07cf55ab-2186-458f-b231-c7f678ea68c5",
  "createdAt": 1790527401103,
  "updatedAt": 1790527401103
}

Find

Get all documents:

const users = (await usersCollection.find()).all();

Example:

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

const users = (await usersCollection.find()).all();

console.log(users);

TypeScript

Collections can be strongly typed using generics:

interface User {
  name: string;
  age: number;
}

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

TypeScript will validate inserted documents:

await users.insert({
  name: "John",
  age: 25
});

For example, this will produce a TypeScript error:

await users.insert({
  name: "John",
  age: "25"
});

because age is defined as a number.

Data Storage

Collections are stored locally as JSON files.

For example:

database/
├── users.json
├── products.json
└── orders.json

The database does not require MongoDB, MySQL, PostgreSQL, or another external database server.

API

DB

Create a database:

const db = new DB("database");

db.collection<T>(name)

Get a collection:

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

collection.insert(document)

Insert a document:

await users.insert({
  name: "John",
  age: 25
});

collection.find()

Retrieve documents:

const result = (await users.find()).all();

Example Project

import { DB } from "db-faker";

interface User {
  name: string;
  age: number;
}

const db = new DB("database");

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

await users.insert({
  name: "John",
  age: 25
});

await users.insert({
  name: "Ali",
  age: 30
});

const result = (await users.find()).all();

console.log(result);

Why db-faker?

db-faker is useful for:

  • Prototyping applications
  • Learning database concepts
  • Local development
  • Testing
  • Small applications
  • Mocking database functionality
  • Projects where a full database server is unnecessary

License

MIT