Type Safety
Available Helpers
import { caseWhen } from '@tablecraft/engine';
import { sql } from 'drizzle-orm';
// ❌ Risky: Raw SQL string
.computed('status', sql`CASE WHEN ${s.users.role} = 'admin' THEN 1 ELSE 0 END`)
// ✅ Type-Safe: Compiler checks column and types
.computed('status', caseWhen(s.users.role, {
'admin': 1,
'user': 0
}, 0)) // Fallback to 0import { column } from '@tablecraft/engine';
const col = column(s.users, 'email'); // ✅ Works
const bad = column(s.users, 'emial'); // ❌ TypeScript Error: Property 'emial' does not existimport { coalesce } from '@tablecraft/engine';
// Returns nickname, or name if nickname is null, or 'Anonymous'
.computed('displayName', coalesce(s.users.nickname, s.users.name, 'Anonymous'))Best Practices
Frontend Type Safety
Generated Types
Type-Safe Hidden Columns
Last updated
Was this helpful?
