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 🙏

© 2025 – Pkg Stats / Ryan Hefner

stratadb

v0.3.2

Published

Type-safe embedded document database for Bun with MongoDB-like queries

Readme

StrataDB

A type-safe embedded document database for Bun. No separate server process, no network overhead - just import and use.

Why Embedded?

Unlike MongoDB or other client-server databases, StrataDB runs in-process with your application:

  • Zero setup - No database server to install or manage
  • Zero latency - Direct memory access, no network round-trips
  • Single file - Your entire database is one portable .db file
  • Serverless ready - Perfect for edge functions, CLI tools, and desktop apps

Features

  • Embedded SQLite - Runs in-process via bun:sqlite, no external dependencies
  • Full Type Safety - Compile-time validation of queries, schemas, and results
  • MongoDB-like API - Familiar operators: $eq, $gt, $in, $and, $or, etc.
  • JSONB Storage - Flexible documents with indexed generated columns
  • Portable - Single file database, easy to backup and deploy
  • Text Search - Multi-field search with case-insensitive matching
  • Cursor Pagination - Efficient, stable pagination for large datasets
  • Field Projection - Clean select/omit helpers for controlling returned fields

Installation

bun add stratadb

Requires Bun runtime.

Note: StrataDB is ESM-only. It does not provide CommonJS exports.

Quick Start

import { Strata, createSchema, type Document } from 'stratadb'

type User = Document<{
  name: string
  email: string
  age: number
}>

const schema = createSchema<User>()
  .field('name', { type: 'TEXT', indexed: true })
  .field('email', { type: 'TEXT', indexed: true, unique: true })
  .field('age', { type: 'INTEGER', indexed: true })
  .timestamps(true)
  .build()

using db = new Strata({ database: 'app.db' })
const users = db.collection('users', schema)

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

// Query
const adults = await users.find({
  age: { $gte: 18 },
  email: { $endsWith: '@example.com' }
})

// Update
await users.updateOne(user._id, { age: 31 })

// Delete
await users.deleteOne(user._id)

// Text search across fields
const results = await users.search('alice', ['name', 'email'])

// Cursor pagination for large datasets
const page1 = await users.find({}, { sort: { createdAt: -1 }, limit: 20 })
const page2 = await users.find(
  {},
  { sort: { createdAt: -1 }, limit: 20, cursor: { after: page1.at(-1)?._id } }
)

// Field projection
const names = await users.find({}, { select: ['name', 'email'] })
const safe = await users.find({}, { omit: ['password'] })

Type Safety

TypeScript validates schema types against field definitions:

// Correct - types match
db.collection<User>('users')
  .field('name', { type: 'TEXT' })      // string -> TEXT
  .field('age', { type: 'INTEGER' })    // number -> INTEGER
  .build()

// Compile error - type mismatch
db.collection<User>('users')
  .field('name', { type: 'INTEGER' })   // Error: string cannot use INTEGER
  .build()

Documentation

See the documentation for complete guides:

Development

bun install      # Install dependencies
bun test         # Run tests
bun run build    # Build
bun run typecheck # Type check

License

MIT