@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 29 lines 758 Bytes
Raw
1 import "./validation.ts";
2 import { defineContract } from "@alchemy.run/prisma/ORM";
3
4 export const contract = defineContract({ extensions: {} }, ({ field, model, rel }) => ({
5 models: {
6 User: model("User", {
7 fields: {
8 id: field.id.uuidv7Native(),
9 email: field.text().unique(),
10 name: field.text(),
11 createdAt: field.temporal.createdAtString(),
12 },
13 relations: {
14 posts: rel.hasMany("Post", { by: "authorId" }),
15 },
16 }),
17
18 Post: model("Post", {
19 fields: {
20 id: field.id.uuidv7Native(),
21 title: field.text(),
22 authorId: field.uuidNative(),
23 },
24 relations: {
25 author: rel.belongsTo("User", { from: "authorId", to: "id" }),
26 },
27 }),
28 },
29 }));