🔶 Show HN: Pylon Sync,一个面向 Agent 的全栈实时框架
英文标题:🔶 Show HN: Pylon Sync, an agent-first full-stack realtime framework
Pylon Sync 展示了一种“Agent 优先”的全栈实时开发方式,开发者只需用 entity() 定义数据模型,即可自动获得同步数据表与类型安全的客户端。框架内置基于 Schema 的访问策略,默认拒绝访问,权限声明式地紧邻模型。在 React 端,通过 db.useQuery 即可实现无 fetch 的实时、类型安全数据查询,大幅简化前后端协同。该设计将对 Agent 集成和开发者体验产生明显影响。
打开原文相关 3 · 机会 1
119.5 KB
197.6 KB
中文
// 一个 entity → 一张同步表 + 类型化客户端
const Order = entity("Order", {
customer: field.string(),
total: field.float(),
paid: field.boolean().default(false),
});
// 访问规则紧邻 schema — 默认拒绝
policy({ entity: "Order",
allowRead: "auth.userId != null",
allowInsert: "auth.userId == data.ownerId",
});
// React 端 — 实时、类型化、无需 fetch
const { data } = db.useQuery("Order");
English / 原文
// one entity → a synced table + typed client
const Order = entity("Order", {
customer: field.string(),
total: field.float(),
paid: field.boolean().default(false),
});
// access rules next to the schema — deny by default
policy({ entity: "Order",
allowRead: "auth.userId != null",
allowInsert: "auth.userId == data.ownerId",
});
// the React side — live, typed, no fetch
const { data } = db.useQuery("Order");