Codync
免费开源的 1:1 Grok Bot 与 Muse 替代方案。可在 iPhone、Mac 或 Linux 桌面上将 Claude 代码、Codex、Cursor 以及 40 多个编码代理作为持久机器人使用。支持群组聊天、线程、应用。
AI 翻译
尚未收集仓库信息。
尚未检测到更新。GitHub 发布版本后会显示在这里。
No compromises TypeScript ORM
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 README ↗A TypeScript ORM for Postgres, SQLite and MySQL with schemas, changesets, composable queries and a repo, typed end to end with no code generation.
select results are
inferred from your classes. No generate step, no schema file to keep in sync.{ success, data } or { success: false, error }.save() on rows. Nothing joins a transaction you did not open; a single call that
writes several statements (a parent with its children, a chunked insertAll) is atomic
on its own.Status: under construction. Nothing is published to npm yet. The design and build plan live in
docs/plan/README.md.
pnpm add egon-orm @egon-orm/postgres pg
Node.js 22.12 or later; ES modules (a CommonJS project can require() them on Node.js 22.12
or later). For SQLite use @egon-orm/sqlite with better-sqlite3; for MySQL,
@egon-orm/mysql with mysql2.
import { postgres } from "@egon-orm/postgres";
import { belongsTo, cast, count, createRepo, from, hasMany, Schema, t, timestamps } from "egon-orm";
// Over two tables with serial (32-bit) keys, which t.integer() reads.
class User extends Schema("users", {
id: t.integer().primaryKey().dbGenerated(),
email: t.string(),
name: t.string().nullable(),
...timestamps(),
}) {
static posts = hasMany(() => Post, { foreignKey: "authorId" });
static changeset(user: User | typeof User, params: unknown) {
return cast(user, params, ["email", "name"]).validateRequired(["email"]).uniqueConstraint("email");
}
}
class Post extends Schema("posts", {
id: t.integer().primaryKey().dbGenerated(),
authorId: t.integer(),
title: t.string(),
}) {
static author = belongsTo(() => User, { foreignKey: "authorId" });
}
const repo = createRepo({ adapter: postgres({ connectionString: process.env.DATABASE_URL }) });
const result = await repo.insert(User.changeset(User, { email: "[email protected]" }));
if (!result.success) console.log(result.error.errorMessages()); // if the email is taken: { email: ["has already been taken"] }
const authors = await repo.all(
from(User, "u")
.where(({ u }) => u.name.isNotNull())
.preload("posts"),
);
authors[0]?.posts[0]?.title; // string: the type knows "posts" was preloaded
const stats = await repo.all(
from(User, "u")
.leftJoinAssoc("u", "posts", "p")
.groupBy(({ u }) => u.id)
.select(({ u, p }) => ({ email: u.email, posts: count(p.id) })),
); // { email: string; posts: number }[]
The documentation site is egon-orm.github.io/egon-orm.
Its pages are Markdown in docs/site, readable here on GitHub too, and
pnpm docs:dev serves the site, API reference included, locally.
| Package | Purpose |
|---|---|
egon-orm | Schemas, types, changesets, queries, the repo; egon-orm/testing and egon-orm/migration |
@egon-orm/postgres | The Postgres adapter (every feature) |
@egon-orm/sqlite, @egon-orm/mysql | The SQLite and MySQL adapters (documented gaps) |
@egon-orm/zod | Zod schemas derived from schema classes |
@egon-orm/cli | The egon command: migrations and development databases |
Requires Node.js 22.12 or newer, pnpm 12 and Docker.
pnpm i
pnpm db:up # Postgres 16 on localhost:54329
pnpm check # lint + typecheck + unit tests + type tests + build
pnpm test:integration # needs the database
pnpm docs:dev # documentation site
See CONTRIBUTING.md for everything else.