You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/tutorials/create-your-first-crud.mdx
+41-41Lines changed: 41 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -316,9 +316,9 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
316
316
.output(
317
317
z.array(
318
318
z.object({
319
-
id: z.string().cuid(),
320
-
name: z.string(),
321
-
description: z.string().optional(),
319
+
id: z.string(),
320
+
name: z.string(),
321
+
description: z.string().optional(),
322
322
})
323
323
)
324
324
),
@@ -350,9 +350,9 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
350
350
.output(
351
351
z.array(
352
352
z.object({
353
-
id: z.string().cuid(),
354
-
name: z.string(),
355
-
description: z.string().nullish(),
353
+
id: z.string(),
354
+
name: z.string(),
355
+
description: z.string().nullish(),
356
356
})
357
357
)
358
358
)
@@ -391,15 +391,15 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
391
391
.input(
392
392
z
393
393
.object({
394
-
cursor: z.string().cuid().optional(),
394
+
cursor: z.string().optional(),
395
395
limit: z.number().min(1).max(100).default(20),
396
396
})
397
-
.default({})
397
+
.prefault({})
398
398
)
399
399
.output(
400
400
z.array(
401
401
z.object({
402
-
id: z.string().cuid(),
402
+
id: z.string(),
403
403
name: z.string(),
404
404
description: z.string().nullish(),
405
405
})
@@ -437,15 +437,15 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
437
437
.input(
438
438
z
439
439
.object({
440
-
cursor: z.string().cuid().optional(),
441
-
limit: z.number().min(1).max(100).default(20),
440
+
cursor: z.string().optional(),
441
+
limit: z.number().min(1).max(100).default(20),
442
442
})
443
-
.default({})
443
+
.prefault({})
444
444
)
445
445
.output(
446
446
z.array(
447
447
z.object({
448
-
id: z.string().cuid(),
448
+
id: z.string(),
449
449
name: z.string(),
450
450
description: z.string().nullish(),
451
451
})
@@ -487,21 +487,21 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
487
487
.input(
488
488
z
489
489
.object({
490
-
cursor: z.string().cuid().optional(),
490
+
cursor: z.string().optional(),
491
491
limit: z.number().min(1).max(100).default(20),
492
492
})
493
-
.default({})
493
+
.prefault({})
494
494
)
495
495
.output(
496
496
z.object({
497
497
items: z.array(
498
498
z.object({
499
-
id: z.string().cuid(),
499
+
id: z.string(),
500
500
name: z.string(),
501
501
description: z.string().nullish(),
502
502
})
503
503
),
504
-
nextCursor: z.string().cuid().nullish(),
504
+
nextCursor: z.string().nullish(),
505
505
})
506
506
)
507
507
.handler(async ({ context, input }) => {
@@ -527,7 +527,7 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
527
527
};
528
528
```
529
529
530
-
We will now add the total of projects in the output data to let the UI know how many projects are available even if now the UI will not request all projects at once.
530
+
We will now add the total of projects in the output data to let the UI know how many projects are available even if the UI will not request all projects at once.
531
531
532
532
```ts {37, 43-44, 53-54, 61}
533
533
// src/server/routers/project.ts
@@ -551,21 +551,21 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
551
551
.input(
552
552
z
553
553
.object({
554
-
cursor: z.string().cuid().optional(),
554
+
cursor: z.string().optional(),
555
555
limit: z.number().min(1).max(100).default(20),
556
556
})
557
-
.default({})
557
+
.prefault({})
558
558
)
559
559
.output(
560
560
z.object({
561
561
items: z.array(
562
562
z.object({
563
-
id: z.string().cuid(),
563
+
id: z.string(),
564
564
name: z.string(),
565
565
description: z.string().nullish(),
566
566
})
567
567
),
568
-
nextCursor: z.string().cuid().nullish(),
568
+
nextCursor: z.string().nullish(),
569
569
total: z.number(),
570
570
})
571
571
)
@@ -623,22 +623,22 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
623
623
.input(
624
624
z
625
625
.object({
626
-
cursor: z.string().cuid().optional(),
626
+
cursor: z.string().optional(),
627
627
limit: z.number().min(1).max(100).default(20),
628
628
searchTerm: z.string().optional(),
629
629
})
630
-
.default({})
630
+
.prefault({})
631
631
)
632
632
.output(
633
633
z.object({
634
634
items: z.array(
635
635
z.object({
636
-
id: z.string().cuid(),
636
+
id: z.string(),
637
637
name: z.string(),
638
638
description: z.string().nullish(),
639
639
})
640
640
),
641
-
nextCursor: z.string().cuid().nullish(),
641
+
nextCursor: z.string().nullish(),
642
642
total: z.number(),
643
643
})
644
644
)
@@ -719,19 +719,19 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
719
719
720
720
First, we will extract the zod schema for the project from the tRPC router and put it into a `schemas.ts` file in the `src/features/projects` folder.
721
721
722
-
Let's create the `app/features/project/schema.ts` file with the zod schema for one project.
722
+
Let's create the `src/features/project/schema.ts` file with the zod schema for one project.
723
723
724
-
```ts filename="app/features/project/schema.ts"
724
+
```ts filename="src/features/project/schema.ts"
725
725
import { z } from"zod";
726
726
727
727
import { zu } from"@/lib/zod/zod-utils";
728
728
729
729
exportconst zProject = () =>
730
-
z.object({
731
-
id: z.string().cuid(),
730
+
z.object({
731
+
id: z.string(),
732
732
name: zu.string.nonEmpty(z.string()),
733
733
description: z.string().nullish(),
734
-
});
734
+
});
735
735
```
736
736
737
737
Let's create the type from this schema.
@@ -743,16 +743,16 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
0 commit comments