Codync
A free, open-source 1:1 alternative to Grok Bot and Muse. Message Claude Code, Codex, Cursor and 40+ coding agents as persistent bots from your iPhone, Mac or Linux desktop. Group chats, threads, appr
A type-safe, PostgreSQL-native ORM for TypeScript with deep relational querying, middleware support, and declarative schema definitions
Developer toolsGitHub @casekitOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
Repository information has not been collected yet.
No updates detected yet. GitHub releases will appear here.
The maker's introduction consists of the line above. Read the repository README for more details. Repository README ↗
Loading the full README.
Read the full README ↗A type-safe, PostgreSQL-native ORM for TypeScript with deep relational querying, middleware support, and declarative schema definitions.
npm add @casekit/orm @casekit/orm-cli @casekit/orm-migrate pg zod
pnpm orm init --directory ./src/db
// src/db/models/author.ts
import type { ModelDefinition } from "@casekit/orm";
import { sql } from "@casekit/sql";
export const author = {
fields: {
id: { type: "serial", primaryKey: true },
name: { type: "text" },
email: { type: "text", unique: true },
createdAt: { type: "timestamptz", default: sql`now()` },
},
relations: {
books: {
type: "1:N",
model: "book",
fromField: "id",
toField: "authorId",
},
},
} as const satisfies ModelDefinition;
// src/db/index.ts
import { orm, type Config } from "@casekit/orm";
import { snakeCase } from "es-toolkit";
import * as models from "./models/index.js";
const config = {
models,
naming: { column: snakeCase },
connection: { database: "myapp" },
} as const satisfies Config;
export const db = orm(config);
pnpm orm db push
import { $ilike } from "@casekit/orm";
const authorsWithBooks = await db.findMany("author", {
select: ["id", "name"],
include: {
books: {
select: ["id", "title"],
where: { published: true },
orderBy: [["title", "asc"]],
limit: 5,
},
},
where: {
email: { [$ilike]: "%@example.com" },
},
});
// Create
const author = await db.createOne("author", {
values: { name: "Jane", email: "[email protected]" },
returning: ["id", "createdAt"],
});
// Read
const authors = await db.findMany("author", {
select: ["id", "name"],
where: { name: { [$ilike]: "%john%" } },
orderBy: [["name", "asc"]],
limit: 10,
});
// Update
await db.updateOne("author", {
set: { name: "Jane Doe" },
where: { id: 1 },
});
// Delete
await db.deleteOne("author", {
where: { id: 1 },
});
await db.transact(async (tx) => {
const author = await tx.createOne("author", {
values: { name: "New Author", email: "[email protected]" },
returning: ["id"],
});
await tx.createOne("book", {
values: { title: "New Book", authorId: author.id },
});
});
Apply cross-cutting concerns like multi-tenancy or automatic timestamps:
const dbWithMiddleware = db.middleware([
tenancy({ org: currentOrg }),
userstamps({ user: currentUser }),
]);
// All queries automatically filtered by org and stamped with user
For complex queries, use raw SQL with type safety via Zod:
import { z } from "zod";
import { sql } from "@casekit/sql";
const results = await db.query(
z.object({ total: z.number() }),
sql`SELECT COUNT(*) as total FROM authors WHERE active = true`
);
| Package | Description |
|---|---|
@casekit/orm | Core ORM library |
@casekit/orm-cli | CLI for init, push, pull, generate |
@casekit/orm-migrate | Schema migration engine |
@casekit/orm-schema | Type definitions |
@casekit/orm-config | Configuration normalization |
@casekit/sql | SQL template literal builder |
Full documentation available at the docs site.
MIT