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?
| Problem | jcell Solution |
|---|---|
| Setting up Postgres/MySQL for a small project | Zero-config file-based storage |
| Heavy ORMs with codegen steps | TypeScript-native schemas, no codegen |
| Wanting type safety without the boilerplate | Full 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 hooks —
before: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'
Quick Links
- Quick Start — get running in 5 minutes
- Core Concepts — schemas, adapters, CRUD
- Query Builder — filtering, sorting, pagination
- API Reference — full type documentation