Generate models
Automatically create Typescript classes that mirror your database tables, constraints, and relationships.
Add script to package
"scripts" {
"db:models": "sync-database-models PATH=./models API_KEY=your_api_key"
}Run the script
npm run db:modelsSample output
import { BaseTable, Column } from '@outerbase/sdk';
export class Users extends BaseTable {
@Column({ name: "id", primary: true })
id: string;
@Column({ name: "email", nullable: false })
email: string;
@Column({ name: "password", nullable: true })
password?: string;
constructor(data: any) {
super({
_name: "users",
_schema: "public"
});
this.id = data.id;
this.email = data.email;
this.password = data.password;
}
}Last updated