@oaknational/oak-curriculum-schema-v2 0.0.5-alpha → 0.0.6-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,17 +15,30 @@ pnpm add @oaknational/oak-curriculum-schema-v2 drizzle-orm zod
15
15
 
16
16
  ```ts
17
17
  import {
18
- draftLessonWithStatusSelectSchema,
19
- type DraftLessonWithStatus,
18
+ draftLessonWithStatusSchema,
19
+ draftLessonWithStatusCamelSchema,
20
+ type DraftLessonWithStatusType,
21
+ type DraftLessonWithStatusCamelType,
20
22
  } from "@oaknational/oak-curriculum-schema-v2";
21
23
 
22
- // Validate a row selected from the draft_lesson_with_status view
23
- const draftLesson = draftLessonWithStatusSelectSchema.parse(row);
24
+ // Validate a snake_case row selected from the draft_lesson_with_status view
25
+ const draftLesson = draftLessonWithStatusSchema.parse(row);
26
+
27
+ // Parse the same snake_case row and get camelCase keys back
28
+ const draftLessonCamel = draftLessonWithStatusCamelSchema.parse(row);
24
29
  ```
25
30
 
26
31
  Raw table schemas are not exported. Schemas for tables live with the
27
32
  service that uses them (for example `mutation-api`).
28
33
 
34
+ ## Naming
35
+
36
+ - Schemas are camelCase with a `Schema` suffix, for example
37
+ `draftLessonWithStatusSchema`.
38
+ - camelCase-key schemas use the suffix `CamelSchema`.
39
+ - Types are PascalCase with a `Type` suffix, or `CamelType` for the
40
+ camelCase-key type.
41
+
29
42
  ## Row types
30
43
 
31
44
  The schema declarations in `types.d.ts` are built by `drizzle-zod` and are
@@ -33,9 +46,9 @@ hard to read. To see a view's fields, hover (or go to definition on) the
33
46
  matching row type, which is `z.infer` of the schema and resolves to a flat
34
47
  list of columns.
35
48
 
36
- | Schema | Select type |
37
- | --- | --- |
38
- | `draftLessonWithStatusSelectSchema` | `DraftLessonWithStatus` |
49
+ | Schema | Type | Camel schema | Camel type |
50
+ | --- | --- | --- | --- |
51
+ | `draftLessonWithStatusSchema` | `DraftLessonWithStatusType` | `draftLessonWithStatusCamelSchema` | `DraftLessonWithStatusCamelType` |
39
52
 
40
53
  ## Links
41
54