How it works
PaperDB is built on one simple idea:
Store JSON documents under collections, with optional schema enforcement — and wrap it all with a fully type-safe SDK.
This is what actually happens under the hood:
1. You define your schema
In your SDK config:
import { createClient } from "paperdb";
const db = createClient({
apiKey: "your_api_key",
schema: {
users: {
properties: {
name: { type: "string", required: true },
email: { type: "string", required: true },
age: { type: "number" },
isAdmin: { type: "boolean" },
},
},
},
});2. You insert documents
Insert a document into your collection:
await db.users.insert({
name: "Richard Hendricks",
email: "richard@piedpiper.com",
age: 28,
});The SDK:
- Applies default values (like isAdmin)
- Adds metadata (_id, createdAt, updatedAt)
- Sends it to the API
The API:
- Validates it against the schema you defined
- Checks for required & unique fields
- Stores it in the database
3. You query like this
const admins = await db.users.find({
filter: { isAdmin: true },
sort: "-createdAt",
limit: 10,
});No SQL needed. No learning curve. You just use JavaScript/TypeScript.
4. You can update, delete, and count too
await db.users.update("abc123", { age: 29 });
await db.users.delete("abc123");
const count = await db.users.count();5. Everything is stored as structured JSON
Data is saved in a key-value store, but the schema you define gives it shape and guarantees — both on the client and the server.
No migrations. No extra tooling. No ORM acrobatics.