一覧へ戻る
Astrolaxis/surrealdb-zod(新しいタブで開きます)
主要言語: TypeScript
Re-useable zod schema's for use with SurrealDB sdk
- star 数
- 5
- watcher 数
- 1
- fork 数
- 1
- issue 数
- 0
- 最終更新
- 2026/06/17
主要言語: TypeScript
Re-useable zod schema's for use with SurrealDB sdk
Re-useable zod schema's for use with SurrealDB sdk.
Install it with:
# using npm npm i surrealdb-zod # or using pnpm pnpm i surrealdb-zod # or using yarn yarn add surrealdb-zod
Next, import the schema's, e.g.:
import { RecordIdSchema } from "surreal-zod";
Use it as you would a normal zod schema
e.g.:
import { RecordIdSchema, RecordIdSchemaOf } from "surreal-zod"; import { z } from "zod"; // `id` must be an instance of class `RecordId` const PersonSchema = z.object({ id: RecordIdSchema, }); // or // `id` must be an instance of class `RecordId` and table must be "person" const PersonSchema = z.object({ id: RecordIdSchemaOf("person"), });
{ClassName}Schema, e.g. for RecordId it is RecordIdSchemaRecordId can be RecordId<"person"> naming will be {ClassName}SchemaOf and will be a functionconst schema = RecordIdSchemaOf("person")Range have required generic types, these schema's are function and follow the following naming scheme: {ClassName}SchemaRangeSchema(z.string(), z.string())string (e.g. RecordIdSchemaOf) and some are any zod schema (e.g. RangeSchema)