Table
A table the migrations made, and the schema each of its rows matches.
Utilização
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' } });
}Declaração do tipo
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>;
}Membros 5
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
namesó de leitura | string | Sim | — |
schemasó de leitura | Schema<T> | Sim | — |
insert | (rows: T | readonly T[]) => Promise<void> | Sim | Inserts every row in one transaction: all of them land, or none. |
update | (where: Where<T>, changes: Partial<T>) => Promise<void> | Sim | — |
delete | (where: Where<T>) => Promise<void> | Sim | Deletes the rows where matches: {} matches every row. |
insert — assinaturas de método
Assinaturas
(rows: T | readonly T[]): Promise<void>Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
rows | T | readonly T[] | Sim | — |
Devolve
Promise<void>
update — assinaturas de método
Assinaturas
(where: Where<T>, changes: Partial<T>): Promise<void>Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
where | Where<T> | Sim | — |
changes | Partial<T> | Sim | — |
Devolve
Promise<void>
delete — assinaturas de método
Assinaturas
(where: Where<T>): Promise<void>Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
where | Where<T> | Sim | — |
Devolve
Promise<void>
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.