QueryBuilder class

Database query builder with fluent interface.

Constructors

constructor constructor

Signature

<T>(): QueryBuilder<T>

Type Parameters

T

The entity type

Methods

execute method

Signature

(): Promise<T[]>

Execute the query.

Returns

Promise resolving to matching entities

orderBy (1/2) method

Signature

(field: keyof T, direction?: "asc" | "desc"): this

Parameters

field

Single field to order by

direction

Sort direction

Returns

This builder for chaining

orderBy (2/2) method

Signature

(fields: keyof T[], direction?: "asc" | "desc"): this

Parameters

fields

Array of fields to order by

direction

Sort direction

Returns

This builder for chaining

take method

Signature

(count: number): this

Pagination: limit to N results.

Parameters

count

Maximum results to return

Returns

This builder for chaining

where method

Signature

(condition: Partial<T>): this

Add a WHERE clause filter.

Parameters

condition

Partial object with filter conditions

Returns

This builder for chaining