Clouzark

TypeScript types

Generate types from your database schema.

clouzark gen types typescript -o src/database.types.ts

The output describes the public schema. For other schemas, list them with --schema; each gets its own key under Database:

clouzark gen types typescript --schema public,career -o src/database.types.ts
type Job = Database['career']['Tables']['jobs']['Row'];

The output includes helpers for the public schema (or the first one listed, without public):

import type { Tables, TablesInsert, TablesUpdate, Enums } from './database.types';

type Order = Tables<'orders'>;            // a row
type NewOrder = TablesInsert<'orders'>;   // generated and defaulted columns are optional
type OrderPatch = TablesUpdate<'orders'>; // every column optional

The full schema is also exported as the Database type. Run the command again after every migration.