Skip to content

Schemas and Types

Astro PocketBase generates schemas and types for your collections

Generic type

The PocketBase SDK provides a generic type for its collections called RecordModel:

interface BaseModel {
[key: string]: any;
id: string;
created: string;
updated: string;
}
interface RecordModel extends BaseModel {
collectionId: string;
collectionName: string;
expand?: {
[key: string]: any;
};
}

Generated types

Zod schemas and types are generated for you and available for each collection in src/lib/pocketbase/schemas:

import { PostsRecord } from "src/lib/pocketbase/schemas";

The default naming is based on the PocketBase SDK convention; so for a collection named posts you will be given access to a PostsRecord schema and a PostsRecord type.