Skip to content

Commit 1af463c

Browse files
fix: remove cuid and replace default with prefault
1 parent 7552fbe commit 1af463c

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

src/content/docs/tutorials/create-your-first-crud.mdx

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
316316
.output(
317317
z.array(
318318
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(),
322322
})
323323
)
324324
),
@@ -350,9 +350,9 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
350350
.output(
351351
z.array(
352352
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(),
356356
})
357357
)
358358
)
@@ -391,15 +391,15 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
391391
.input(
392392
z
393393
.object({
394-
cursor: z.string().cuid().optional(),
394+
cursor: z.string().optional(),
395395
limit: z.number().min(1).max(100).default(20),
396396
})
397-
.default({})
397+
.prefault({})
398398
)
399399
.output(
400400
z.array(
401401
z.object({
402-
id: z.string().cuid(),
402+
id: z.string(),
403403
name: z.string(),
404404
description: z.string().nullish(),
405405
})
@@ -437,15 +437,15 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
437437
.input(
438438
z
439439
.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),
442442
})
443-
.default({})
443+
.prefault({})
444444
)
445445
.output(
446446
z.array(
447447
z.object({
448-
id: z.string().cuid(),
448+
id: z.string(),
449449
name: z.string(),
450450
description: z.string().nullish(),
451451
})
@@ -487,21 +487,21 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
487487
.input(
488488
z
489489
.object({
490-
cursor: z.string().cuid().optional(),
490+
cursor: z.string().optional(),
491491
limit: z.number().min(1).max(100).default(20),
492492
})
493-
.default({})
493+
.prefault({})
494494
)
495495
.output(
496496
z.object({
497497
items: z.array(
498498
z.object({
499-
id: z.string().cuid(),
499+
id: z.string(),
500500
name: z.string(),
501501
description: z.string().nullish(),
502502
})
503503
),
504-
nextCursor: z.string().cuid().nullish(),
504+
nextCursor: z.string().nullish(),
505505
})
506506
)
507507
.handler(async ({ context, input }) => {
@@ -527,7 +527,7 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
527527
};
528528
```
529529

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.
531531

532532
```ts {37, 43-44, 53-54, 61}
533533
// src/server/routers/project.ts
@@ -551,21 +551,21 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
551551
.input(
552552
z
553553
.object({
554-
cursor: z.string().cuid().optional(),
554+
cursor: z.string().optional(),
555555
limit: z.number().min(1).max(100).default(20),
556556
})
557-
.default({})
557+
.prefault({})
558558
)
559559
.output(
560560
z.object({
561561
items: z.array(
562562
z.object({
563-
id: z.string().cuid(),
563+
id: z.string(),
564564
name: z.string(),
565565
description: z.string().nullish(),
566566
})
567567
),
568-
nextCursor: z.string().cuid().nullish(),
568+
nextCursor: z.string().nullish(),
569569
total: z.number(),
570570
})
571571
)
@@ -623,22 +623,22 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
623623
.input(
624624
z
625625
.object({
626-
cursor: z.string().cuid().optional(),
626+
cursor: z.string().optional(),
627627
limit: z.number().min(1).max(100).default(20),
628628
searchTerm: z.string().optional(),
629629
})
630-
.default({})
630+
.prefault({})
631631
)
632632
.output(
633633
z.object({
634634
items: z.array(
635635
z.object({
636-
id: z.string().cuid(),
636+
id: z.string(),
637637
name: z.string(),
638638
description: z.string().nullish(),
639639
})
640640
),
641-
nextCursor: z.string().cuid().nullish(),
641+
nextCursor: z.string().nullish(),
642642
total: z.number(),
643643
})
644644
)
@@ -719,19 +719,19 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
719719

720720
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.
721721

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.
723723

724-
```ts filename="app/features/project/schema.ts"
724+
```ts filename="src/features/project/schema.ts"
725725
import { z } from "zod";
726726

727727
import { zu } from "@/lib/zod/zod-utils";
728728

729729
export const zProject = () =>
730-
z.object({
731-
id: z.string().cuid(),
730+
z.object({
731+
id: z.string(),
732732
name: zu.string.nonEmpty(z.string()),
733733
description: z.string().nullish(),
734-
});
734+
});
735735
```
736736

737737
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
743743

744744
export type Project = z.infer<ReturnType<typeof zProject>>;
745745
export const zProject = () =>
746-
z.object({
747-
id: z.string().cuid(),
746+
z.object({
747+
id: z.string(),
748748
name: zu.string.nonEmpty(z.string()),
749749
description: z.string().nullish(),
750-
});
750+
});
751751
```
752752

753-
Use this schema in the oRPC router in the `app/server/routers/project.ts` file.
753+
Use this schema in the oRPC router in the `src/server/routers/project.ts` file.
754754

755-
```ts {4, 19} filename="app/server/routers/project.ts"
755+
```ts {4, 19} filename="src/server/routers/project.ts"
756756
import { Prisma } from "@prisma/client";
757757
import { z } from "zod";
758758

@@ -762,19 +762,19 @@ We will create a **"Project"** entity with the full CRUD (Create Read Update Del
762762
const tags = ["projects"];
763763

764764
export default {
765-
getAll: protectedProcedure({
765+
getAll: protectedProcedure({
766766
permission: {
767767
project: ["read"],
768768
},
769-
})
769+
})
770770
.route(/* ... */)
771771
.input(/* ... */)
772772
.output(
773-
z.object({
773+
z.object({
774774
items: z.array(zProject()),
775-
nextCursor: z.string().cuid().nullish(),
775+
nextCursor: z.string().nullish(),
776776
total: z.number(),
777-
})
777+
})
778778
)
779779
.handler(/* ... */),
780780
};

0 commit comments

Comments
 (0)