Skip to content

How It Works

Astroladb follows a simple principle: define once, generate everything.

Your .js schema files are the single source of truth. From them, Astroladb generates:

CommandOutputPurpose
alab migrateSQL migrationsUpdate your database
alab export -f typescript.ts filesType-safe code
alab export -f openapiopenapi.yamlAPI documentation

Define your data model:

schemas/blog/post.js
export default table({
id: col.id(),
title: col.title(),
content: col.body(),
published: col.flag(false),
}).timestamps();

Run migration:

Terminal window
alab new create_posts
alab migrate
# → migrations/001_create_posts.sql generated
# → Applied to database

Export TypeScript types from the same schema:

Terminal window
alab export -f typescript
// types/blog/post.ts (generated)
export interface Post {
id: string;
title: string;
content: string;
published: boolean;
created_at: Date;
updated_at: Date;
}

The key insight: your schema is not tied to any single output format.

post.js
├── PostgreSQL table
├── TypeScript interface
├── Go struct
├── Python dataclass
├── OpenAPI schema
└── GraphQL types

Change your schema once, regenerate everything. No manual sync required.