Skip to content

Commit 883309e

Browse files
committed
feat(sqlite-demo): add M:N ORM client examples + seed + CLI commands
Adds five ORM client modules exercising the Post↔Tag N:M relation: - get-post-tags: .include('tags', ...) — include read across junction - get-posts-by-tag-filter: .some()/.none()/.every() on N:M relation - connect-post-tags: update + t.connect([{id}]) callback mutator - disconnect-post-tags: update + t.disconnect([{id}]) callback mutator - create-post-with-tags: create + t.create([...]) nested mutation Seed extended with Tag rows + junction rows (typescript/orm/demo tags linked to First Post and Second Post). CLI commands registered in main.ts. Migration refs committed for offline db:init reproducibility. Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
1 parent 72ef8b7 commit 883309e

10 files changed

Lines changed: 1294 additions & 6 deletions

File tree

examples/prisma-next-demo-sqlite/migrations/app/refs/db.contract.d.ts

Lines changed: 673 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 341 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,341 @@
1+
{
2+
"_generated": {
3+
"message": "This file is automatically generated by \"prisma-next contract emit\".",
4+
"regenerate": "To regenerate, run: prisma-next contract emit",
5+
"warning": "⚠️ GENERATED FILE - DO NOT EDIT"
6+
},
7+
"capabilities": {
8+
"sql": {
9+
"foreignKeys": true,
10+
"jsonAgg": true,
11+
"limit": true,
12+
"orderBy": true,
13+
"returning": true
14+
}
15+
},
16+
"domain": {
17+
"namespaces": {
18+
"__unbound__": {
19+
"models": {
20+
"Post": {
21+
"fields": {
22+
"createdAt": {
23+
"nullable": false,
24+
"type": { "codecId": "sqlite/datetime@1", "kind": "scalar" }
25+
},
26+
"id": {
27+
"nullable": false,
28+
"type": {
29+
"codecId": "sql/char@1",
30+
"kind": "scalar",
31+
"typeParams": { "length": 36 }
32+
}
33+
},
34+
"title": {
35+
"nullable": false,
36+
"type": { "codecId": "sqlite/text@1", "kind": "scalar" }
37+
},
38+
"userId": {
39+
"nullable": false,
40+
"type": {
41+
"codecId": "sql/char@1",
42+
"kind": "scalar",
43+
"typeParams": { "length": 36 }
44+
}
45+
}
46+
},
47+
"relations": {
48+
"tags": {
49+
"cardinality": "N:M",
50+
"on": { "localFields": ["id"], "targetFields": ["postId"] },
51+
"through": {
52+
"childColumns": ["tagId"],
53+
"parentColumns": ["postId"],
54+
"table": "post_tag",
55+
"targetColumns": ["id"]
56+
},
57+
"to": { "model": "Tag", "namespace": "__unbound__" }
58+
},
59+
"user": {
60+
"cardinality": "N:1",
61+
"on": { "localFields": ["userId"], "targetFields": ["id"] },
62+
"to": { "model": "User", "namespace": "__unbound__" }
63+
}
64+
},
65+
"storage": {
66+
"fields": {
67+
"createdAt": { "column": "createdAt" },
68+
"id": { "column": "id" },
69+
"title": { "column": "title" },
70+
"userId": { "column": "userId" }
71+
},
72+
"table": "post"
73+
}
74+
},
75+
"PostTag": {
76+
"fields": {
77+
"postId": {
78+
"nullable": false,
79+
"type": {
80+
"codecId": "sql/char@1",
81+
"kind": "scalar",
82+
"typeParams": { "length": 36 }
83+
}
84+
},
85+
"tagId": {
86+
"nullable": false,
87+
"type": {
88+
"codecId": "sql/char@1",
89+
"kind": "scalar",
90+
"typeParams": { "length": 36 }
91+
}
92+
}
93+
},
94+
"relations": {},
95+
"storage": {
96+
"fields": { "postId": { "column": "postId" }, "tagId": { "column": "tagId" } },
97+
"table": "post_tag"
98+
}
99+
},
100+
"Tag": {
101+
"fields": {
102+
"id": {
103+
"nullable": false,
104+
"type": {
105+
"codecId": "sql/char@1",
106+
"kind": "scalar",
107+
"typeParams": { "length": 36 }
108+
}
109+
},
110+
"label": {
111+
"nullable": false,
112+
"type": { "codecId": "sqlite/text@1", "kind": "scalar" }
113+
}
114+
},
115+
"relations": {
116+
"posts": {
117+
"cardinality": "N:M",
118+
"on": { "localFields": ["id"], "targetFields": ["tagId"] },
119+
"through": {
120+
"childColumns": ["postId"],
121+
"parentColumns": ["tagId"],
122+
"table": "post_tag",
123+
"targetColumns": ["id"]
124+
},
125+
"to": { "model": "Post", "namespace": "__unbound__" }
126+
}
127+
},
128+
"storage": {
129+
"fields": { "id": { "column": "id" }, "label": { "column": "label" } },
130+
"table": "tag"
131+
}
132+
},
133+
"User": {
134+
"fields": {
135+
"createdAt": {
136+
"nullable": false,
137+
"type": { "codecId": "sqlite/datetime@1", "kind": "scalar" }
138+
},
139+
"displayName": {
140+
"nullable": false,
141+
"type": { "codecId": "sqlite/text@1", "kind": "scalar" }
142+
},
143+
"email": {
144+
"nullable": false,
145+
"type": { "codecId": "sqlite/text@1", "kind": "scalar" }
146+
},
147+
"id": {
148+
"nullable": false,
149+
"type": {
150+
"codecId": "sql/char@1",
151+
"kind": "scalar",
152+
"typeParams": { "length": 36 }
153+
}
154+
}
155+
},
156+
"relations": {
157+
"posts": {
158+
"cardinality": "1:N",
159+
"on": { "localFields": ["id"], "targetFields": ["userId"] },
160+
"to": { "model": "Post", "namespace": "__unbound__" }
161+
}
162+
},
163+
"storage": {
164+
"fields": {
165+
"createdAt": { "column": "createdAt" },
166+
"displayName": { "column": "displayName" },
167+
"email": { "column": "email" },
168+
"id": { "column": "id" }
169+
},
170+
"table": "user"
171+
}
172+
}
173+
}
174+
}
175+
}
176+
},
177+
"execution": {
178+
"executionHash": "sha256:70c6ceb0ed79d5888519ec84bf32e31a056283fa8d5c7b5c1ba65b709f8595c8",
179+
"mutations": {
180+
"defaults": [
181+
{
182+
"onCreate": { "id": "uuidv4", "kind": "generator" },
183+
"ref": { "column": "id", "table": "post" }
184+
},
185+
{
186+
"onCreate": { "id": "uuidv4", "kind": "generator" },
187+
"ref": { "column": "id", "table": "tag" }
188+
},
189+
{
190+
"onCreate": { "id": "uuidv4", "kind": "generator" },
191+
"ref": { "column": "id", "table": "user" }
192+
}
193+
]
194+
}
195+
},
196+
"extensionPacks": {},
197+
"meta": {},
198+
"profileHash": "sha256:3cc333ecad9f3f4c7229370a9d2c37e908cdce0f8d2e9fb132d50605b024eff2",
199+
"roots": {
200+
"post": { "model": "Post", "namespace": "__unbound__" },
201+
"post_tag": { "model": "PostTag", "namespace": "__unbound__" },
202+
"tag": { "model": "Tag", "namespace": "__unbound__" },
203+
"user": { "model": "User", "namespace": "__unbound__" }
204+
},
205+
"schemaVersion": "1",
206+
"storage": {
207+
"namespaces": {
208+
"__unbound__": {
209+
"id": "__unbound__",
210+
"tables": {
211+
"post": {
212+
"columns": {
213+
"createdAt": {
214+
"codecId": "sqlite/datetime@1",
215+
"default": { "expression": "now()", "kind": "function" },
216+
"nativeType": "text",
217+
"nullable": false
218+
},
219+
"id": {
220+
"codecId": "sql/char@1",
221+
"nativeType": "character",
222+
"nullable": false,
223+
"typeParams": { "length": 36 }
224+
},
225+
"title": { "codecId": "sqlite/text@1", "nativeType": "text", "nullable": false },
226+
"userId": {
227+
"codecId": "sql/char@1",
228+
"nativeType": "character",
229+
"nullable": false,
230+
"typeParams": { "length": 36 }
231+
}
232+
},
233+
"foreignKeys": [
234+
{
235+
"constraint": true,
236+
"index": true,
237+
"name": "post_userId_fkey",
238+
"source": {
239+
"columns": ["userId"],
240+
"namespaceId": "__unbound__",
241+
"tableName": "post"
242+
},
243+
"target": { "columns": ["id"], "namespaceId": "__unbound__", "tableName": "user" }
244+
}
245+
],
246+
"indexes": [],
247+
"primaryKey": { "columns": ["id"] },
248+
"uniques": []
249+
},
250+
"post_tag": {
251+
"columns": {
252+
"postId": {
253+
"codecId": "sql/char@1",
254+
"nativeType": "character",
255+
"nullable": false,
256+
"typeParams": { "length": 36 }
257+
},
258+
"tagId": {
259+
"codecId": "sql/char@1",
260+
"nativeType": "character",
261+
"nullable": false,
262+
"typeParams": { "length": 36 }
263+
}
264+
},
265+
"foreignKeys": [
266+
{
267+
"constraint": true,
268+
"index": true,
269+
"name": "post_tag_postId_fkey",
270+
"source": {
271+
"columns": ["postId"],
272+
"namespaceId": "__unbound__",
273+
"tableName": "post_tag"
274+
},
275+
"target": { "columns": ["id"], "namespaceId": "__unbound__", "tableName": "post" }
276+
},
277+
{
278+
"constraint": true,
279+
"index": true,
280+
"name": "post_tag_tagId_fkey",
281+
"source": {
282+
"columns": ["tagId"],
283+
"namespaceId": "__unbound__",
284+
"tableName": "post_tag"
285+
},
286+
"target": { "columns": ["id"], "namespaceId": "__unbound__", "tableName": "tag" }
287+
}
288+
],
289+
"indexes": [],
290+
"primaryKey": { "columns": ["postId", "tagId"], "name": "post_tag_pkey" },
291+
"uniques": []
292+
},
293+
"tag": {
294+
"columns": {
295+
"id": {
296+
"codecId": "sql/char@1",
297+
"nativeType": "character",
298+
"nullable": false,
299+
"typeParams": { "length": 36 }
300+
},
301+
"label": { "codecId": "sqlite/text@1", "nativeType": "text", "nullable": false }
302+
},
303+
"foreignKeys": [],
304+
"indexes": [],
305+
"primaryKey": { "columns": ["id"] },
306+
"uniques": []
307+
},
308+
"user": {
309+
"columns": {
310+
"createdAt": {
311+
"codecId": "sqlite/datetime@1",
312+
"default": { "expression": "now()", "kind": "function" },
313+
"nativeType": "text",
314+
"nullable": false
315+
},
316+
"displayName": {
317+
"codecId": "sqlite/text@1",
318+
"nativeType": "text",
319+
"nullable": false
320+
},
321+
"email": { "codecId": "sqlite/text@1", "nativeType": "text", "nullable": false },
322+
"id": {
323+
"codecId": "sql/char@1",
324+
"nativeType": "character",
325+
"nullable": false,
326+
"typeParams": { "length": 36 }
327+
}
328+
},
329+
"foreignKeys": [],
330+
"indexes": [],
331+
"primaryKey": { "columns": ["id"] },
332+
"uniques": []
333+
}
334+
}
335+
}
336+
},
337+
"storageHash": "sha256:194cf0bce4a19c7191f9e4ae8670de21707c48678d7b8998d38708a506488c88"
338+
},
339+
"target": "sqlite",
340+
"targetFamily": "sql"
341+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"hash": "sha256:194cf0bce4a19c7191f9e4ae8670de21707c48678d7b8998d38708a506488c88",
3+
"invariants": []
4+
}

0 commit comments

Comments
 (0)