Usage

Reuse a filter when querying a typed table.

tsx
// 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

ts
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

NameTypeRequiredDescription
namereadonlystringYes—
schemareadonlySchema<T>Yes—
insert(rows: T | readonly T[]) => Promise<void>YesInserts 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>YesDeletes the rows where matches: {} matches every row.
insert — method signatures

Signatures

ts
(rows: T | readonly T[]): Promise<void>

Parameters

NameTypeRequiredDescription
rowsT | readonly T[]Yes—

Returns

Promise<void>

update — method signatures

Signatures

ts
(where: Where<T>, changes: Partial<T>): Promise<void>

Parameters

NameTypeRequiredDescription
whereWhere<T>Yes—
changesPartial<T>Yes—

Returns

Promise<void>

delete — method signatures

Signatures

ts
(where: Where<T>): Promise<void>

Parameters

NameTypeRequiredDescription
whereWhere<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.