@oaknational/oak-curriculum-schema-v2 0.0.4 → 0.0.5-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,23 +15,27 @@ pnpm add @oaknational/oak-curriculum-schema-v2 drizzle-orm zod
15
15
 
16
16
  ```ts
17
17
  import {
18
- lessonSelectSchema,
19
- lessonInsertSchema,
20
- lessonPublishedSchema,
21
- type Lesson,
22
- type LessonInsert,
23
- type LessonPublished,
18
+ draftLessonWithStatusSelectSchema,
19
+ type DraftLessonWithStatus,
24
20
  } from "@oaknational/oak-curriculum-schema-v2";
25
21
 
26
- // Validate a full row selected from the database
27
- const lesson = lessonSelectSchema.parse(row);
22
+ // Validate a row selected from the draft_lesson_with_status view
23
+ const draftLesson = draftLessonWithStatusSelectSchema.parse(row);
24
+ ```
28
25
 
29
- // Validate a row before inserting
30
- const newLesson = lessonInsertSchema.parse(payload);
26
+ Raw table schemas are not exported. Schemas for tables live with the
27
+ service that uses them (for example `mutation-api`).
31
28
 
32
- // A schema extended from the derived base to narrow to published rows
33
- const publishedLesson = lessonPublishedSchema.parse(row);
34
- ```
29
+ ## Row types
30
+
31
+ The schema declarations in `types.d.ts` are built by `drizzle-zod` and are
32
+ hard to read. To see a view's fields, hover (or go to definition on) the
33
+ matching row type, which is `z.infer` of the schema and resolves to a flat
34
+ list of columns.
35
+
36
+ | Schema | Select type |
37
+ | --- | --- |
38
+ | `draftLessonWithStatusSelectSchema` | `DraftLessonWithStatus` |
35
39
 
36
40
  ## Links
37
41