Type Utilities
tsql exports utility types that read from your schema.
import type { Insertable, Table, TableRow, Updatable } from "@bms/tsql";
import { schema } from "./schema";
type UserA = Table<typeof schema, "users">;
type UserB = TableRow<typeof schema, "users">;
type NewUser = Insertable<typeof schema, "users">;
type UserPatch = Updatable<typeof schema, "users">;
Type meanings
Table/TableRow: full table row shapeInsertable: object accepted byinsert(...).values(...)Updatable: object accepted byupdate(...).set(...)
Insertable and Updatable are intentionally permissive (Partial-style) to support partial writes and DB defaults.
Expression types
Expr<T>: typed SQL expressionOrderExpr: ordering expression (asc/desc)
You usually consume these through query callbacks, but they are also useful in helper functions.