Skip to main content

Welcome to jcell

jcell is a lightweight, type-safe document database + ORM for TypeScript. Think of it as an embedded database that speaks JSON — no external server, no codegen, no heavy dependencies.

import { createDB, schema, t, fileAdapter } from '@sajjadbzn/jcell'

const userSchema = schema({
id: t.id(),
name: t.string(),
role: t.enum(['admin', 'user'] as const),
createdAt: t.date().default(() => new Date()),
})

const db = createDB({ adapter: fileAdapter({ path: './data' }) })
const users = db.collection('users', userSchema)

// Full TypeScript inference ✨
const user = await users.insert({ name: 'Alice', role: 'admin' })
const found = await users.where('name').eq('Alice').first()

Why jcell?

Problemjcell Solution
Setting up Postgres/MySQL for a small projectZero-config file-based storage
Heavy ORMs with codegen stepsTypeScript-native schemas, no codegen
Wanting type safety without the boilerplateFull type inference from schema definitions
Multiple runtimes (Node, Bun, Workers)Same API, pluggable adapters

Features at a Glance

  • Zero dependencies — install and go
  • 4 storage adapters — file, memory, SQLite, Cloudflare D1
  • Full TypeScript inference — schemas drive types
  • Built-in validation — validate on insert/update
  • Powerful query builder — chainable filters with where, orderBy, limit, etc.
  • Aggregation pipeline — MongoDB-style $match, $group, $sum, $avg
  • Lifecycle hooksbefore:insert, after:update, etc.
  • Transactions — for SQLite and D1 adapters
  • Migrations — named, reversible, auto-tracked
  • Indexes — in-memory and SQL-level
  • Studio UI — visual database browser (separate package)

Installation

npm install @sajjadbzn/jcell
# or
bun add @sajjadbzn/jcell

Single package — everything included. All adapters and the core are bundled together.

For Cloudflare Workers, use the D1 import path (avoids Node.js APIs):

import { d1Adapter } from '@sajjadbzn/jcell/d1'