db.Table
A table the migrations made, and the schema each of its rows matches.
Usage
Reuse a filter when querying a typed table.
// Reuse a filter when querying a typed table.
import { db, type Comparison, type Table } from 'kuito';
type Product = { id: string; price: number };
export function affordableProducts(products: Table<Product>) {
const price: Comparison<number> = { gte: 0, lte: 50 };
return db.query(products, { where: { price }, orderBy: { price: 'asc' } });
}Type declaration
export interface Table<T> {
readonly name: string;
readonly schema: Schema<T>;
/** Inserts every row in one transaction: all of them land, or none. */
insert(rows: T | readonly T[]): Promise<void>;
update(where: Where<T>, changes: Partial<T>): Promise<void>;
/** Deletes the rows `where` matches: `{}` matches every row. */
delete(where: Where<T>): Promise<void>;
}Members 5
| Name | Type | Required | Description |
|---|---|---|---|
namereadonly | string | Yes | — |
schemareadonly | Schema<T> | Yes | — |
insert | (rows: T | readonly T[]) => Promise<void> | Yes | Inserts every row in one transaction: all of them land, or none. |
update | (where: Where<T>, changes: Partial<T>) => Promise<void> | Yes | — |
delete | (where: Where<T>) => Promise<void> | Yes | Deletes the rows where matches: {} matches every row. |
insert — method signatures
Signatures
(rows: T | readonly T[]): Promise<void>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
rows | T | readonly T[] | Yes | — |
Returns
Promise<void>
update — method signatures
Signatures
(where: Where<T>, changes: Partial<T>): Promise<void>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
where | Where<T> | Yes | — |
changes | Partial<T> | Yes | — |
Returns
Promise<void>
delete — method signatures
Signatures
(where: Where<T>): Promise<void>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
where | Where<T> | Yes | — |
Returns
Promise<void>
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.