db.Table
A table the migrations made, and the schema each of its rows matches.
Verwendung
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' } });
}Typdeklaration
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>;
}Mitglieder 5
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
nameschreibgeschützt | string | Ja | — |
schemaschreibgeschützt | Schema<T> | Ja | — |
insert | (rows: T | readonly T[]) => Promise<void> | Ja | Inserts every row in one transaction: all of them land, or none. |
update | (where: Where<T>, changes: Partial<T>) => Promise<void> | Ja | — |
delete | (where: Where<T>) => Promise<void> | Ja | Deletes the rows where matches: {} matches every row. |
insert — Methodensignaturen
Signaturen
(rows: T | readonly T[]): Promise<void>Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
rows | T | readonly T[] | Ja | — |
Rückgabe
Promise<void>
update — Methodensignaturen
Signaturen
(where: Where<T>, changes: Partial<T>): Promise<void>Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
where | Where<T> | Ja | — |
changes | Partial<T> | Ja | — |
Rückgabe
Promise<void>
delete — Methodensignaturen
Signaturen
(where: Where<T>): Promise<void>Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
where | Where<T> | Ja | — |
Rückgabe
Promise<void>
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.