Comparison
Comparisons of one column's value: a row matches when every one holds.
Utilisation
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' } });
}Déclaration du type
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;
}Membres 7
| Nom | Type | Requis | Description |
|---|---|---|---|
gt | Extract<V, string | number> | Non | — |
gte | Extract<V, string | number> | Non | — |
lt | Extract<V, string | number> | Non | — |
lte | Extract<V, string | number> | Non | — |
not | V | Non | Rows whose column isn't this value: NULL isn't 'a', and { not: null } is every non-NULL. |
in | readonly V[] | Non | Rows whose column is one of these; null among them matches NULL. |
like | [Extract<V, string>] extends [never] ? never : string | Non | SQL's LIKE: % is any run of characters, _ one; ASCII letters match either case. |
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.