Schema

A schema is a Zod schema for validating data. Vela uses TypeScript definitions to ensure that the Zod schema is kept in sync with the database schema. If fields isn’t provided, the schema will be generated based on the existing database schema.

Syntax

$ vela generate schema [model] [fields...]
$ vela generate schema categories name:text

This will create a Zod schema for a resource. The file created is:

src/lib/schemas/category.ts

No database collection is created — use resource for that. The command works in any SvelteKit project, with or without a backend, and installs zod if the project doesn’t have it.

Options

  • --ai <description> - Design the schema with AI from a natural-language description

AI

Pro

--ai designs the schema from a natural-language description. Pass a description instead of a model name and fields — passing both is an error.

$ vela generate schema --ai "a cooking recipe with ingredients and amounts"

Requires an account and a linked project — run vela login and vela link first.