Schema
Start with shorthand. Add builders only when needed.
Schema
Simple mode first
import { table } from '@shyk/kadak-orm'
export const users = table('users', {
id: 'id',
email: 'email',
name: 'text',
age: 'int?',
isActive: 'boolean',
createdAt: 'timestamp',
})| Shorthand | Meaning |
|---|---|
'id' | primary key |
'text' | string |
'int' | number |
'int?' | optional number |
'email' | string + validation |
'boolean' | boolean |
'timestamp' | date |
Advanced builder
import { z } from 'zod'
import { table, kadak } from '@shyk/kadak-orm'
export const users = table('users', {
id: kadak.id(),
email: kadak.email().unique(),
name: kadak.text().min(2).max(120),
profile: kadak.json(z.object({ theme: z.enum(['light', 'dark']) })),
updatedAt: kadak.timestamp().default('now').autoUpdate(),
})Deep reference for all kadak.* methods and SQL equivalents: Column Methods.