UNPKG

@dudousxd/nestjs-filter-drizzle

Version:

Drizzle ORM adapter for @dudousxd/nestjs-filter.

44 lines • 2.12 kB
import { BaseFilter } from '@dudousxd/nestjs-filter'; import type { Table } from 'drizzle-orm'; import type { DrizzleQuery } from './drizzle-query.js'; /** * Base class for Drizzle filters. `this.$query` is a {@link DrizzleQuery} over * the table given to `@Filterable({ entity })`: * * ```ts * @Injectable() * @Filterable({ entity: users }) * export class UserFilter extends DrizzleFilter<typeof users> { * @FilterFor('minAge') * applyMinAge(value: number) { * this.$query.where(gte(users.age, value)); * } * } * ``` * * Build conditions with drizzle's own operators against the imported table — * or through {@link columns} when the same filter also runs as a relation * filter (`@Relations`), where the query targets an ALIAS of the table. */ export declare abstract class DrizzleFilter<TTable extends Table = Table> extends BaseFilter<DrizzleQuery<TTable>> { /** * The queried table's columns, as seen by the current query (the alias * inside a relation subquery). Prefer this over the imported table object in * filters that are also used through `@Relations`. */ protected get columns(): TTable['_']['columns']; private columnOf; /** * Adds a LIKE condition: `field LIKE '%value%'` (value is escaped). Matching * follows the database's LIKE semantics — case-sensitive on Postgres; use * {@link whereILike} for case-insensitive matching on every dialect. */ protected whereLike(field: keyof TTable['_']['columns'] & string, value: string): void; /** Case-insensitive contains: `ILIKE` on Postgres, `lower(x) LIKE lower(p)` elsewhere. */ protected whereILike(field: keyof TTable['_']['columns'] & string, value: string): void; /** Adds a LIKE condition: `field LIKE 'value%'` (value is escaped). */ protected whereBeginsWith(field: keyof TTable['_']['columns'] & string, value: string): void; /** Adds a LIKE condition: `field LIKE '%value'` (value is escaped). */ protected whereEndsWith(field: keyof TTable['_']['columns'] & string, value: string): void; } //# sourceMappingURL=drizzle-filter.d.ts.map