Logo VelaStack

Generate a resource

Define a model once and get its PocketBase collection and Zod schema in a single command. Creates src/lib/schemas/<name>.ts from the field list and, when run through the CLI, provisions the matching collection in PocketBase. Nested model paths like users/posts and relation shorthands such as author:current_user are supported, mirroring the field DSL used across the other generators. Use it when you need the data layer without the CRUD UI.

$ vela generate resource
src/lib/schemas/contact.ts
import { z } from "zod";
import type { Schemas } from "@velastack/pocketbase";

export const contactSchema = z.object({
  id: z.string().optional(),
  collectionId: z.string().optional(),
  name: z.string().optional(),
  email: z.email().optional(),
}) satisfies Schemas["contacts"];