Comparison
Comparisons of one column's value: a row matches when every one holds.
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 Comparison<V> {
gt?: Extract<V, string | number>;
gte?: Extract<V, string | number>;
lt?: Extract<V, string | number>;
lte?: Extract<V, string | number>;
/** Rows whose column isn't this value: NULL isn't `'a'`, and `{ not: null }` is every non-NULL. */
not?: V;
/** Rows whose column is one of these; `null` among them matches NULL. */
in?: readonly V[];
/** SQL's LIKE: `%` is any run of characters, `_` one; ASCII letters match either case. */
like?: [Extract<V, string>] extends [never] ? never : string;
}Mitglieder 7
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
gt | Extract<V, string | number> | Nein | — |
gte | Extract<V, string | number> | Nein | — |
lt | Extract<V, string | number> | Nein | — |
lte | Extract<V, string | number> | Nein | — |
not | V | Nein | Rows whose column isn't this value: NULL isn't 'a', and { not: null } is every non-NULL. |
in | readonly V[] | Nein | Rows whose column is one of these; null among them matches NULL. |
like | [Extract<V, string>] extends [never] ? never : string | Nein | SQL's LIKE: % is any run of characters, _ one; ASCII letters match either case. |
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.