Clouzark

TypeScript types

Generate types from your database schema.

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

The output describes the public schema and includes helpers:

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.