Three-layer architecture
Tables for storage, views for access, Business Objects for lifecycle. Application code only talks to views.
Tables, views, domains, auto-migration, native i18n — built on PostgreSQL, with zero codegen.
npm install @pgbo/coreimport { createDatabase } from '@pgbo/core'
import { table, view, text, integer } from '@pgbo/core/schema'
const warehouse = table('warehouse', {
columns: {
slug: text().notNull(),
name: text().notNull(),
capacity: integer().min(0),
},
primaryKey: ['slug'],
})
const warehouseView = view('warehouse_view').from(warehouse)
const db = createDatabase({ connectionString: 'postgresql://localhost/mydb' })
const rows = await db.from(warehouseView).execute()┌─────────────────────────────────────────────────┐
│ Business Object (BO) │
│ Marks a view as a managed entity. │
│ Owns CRUD lifecycle, permissions, hooks. │
├─────────────────────────────────────────────────┤
│ View │
│ PostgreSQL VIEW — the read/write interface. │
│ Application code only talks to views. │
├─────────────────────────────────────────────────┤
│ Table │
│ PostgreSQL TABLE — pure data storage. │
│ Never accessed directly by application code. │
└─────────────────────────────────────────────────┘Application code never touches tables directly. All reads and writes flow through views. Views become Business Objects when they need CRUD lifecycle, permissions, and hooks.
Next steps — read the Architecture overview, then dive into Schema Definition, Query Builder, or Business Objects.