Skip to content

SelectQueryOptions

Defined in: define/table/types/query.ts:32

Defines the options available for a SELECT query.

// Find all active users, order by name, and fetch their posts
const activeUsers = await User.find({
where: 'isActive = true',
orderBy: [{ field: 'name', order: 'ASC' }],
fetch: ['posts'],
limit: 50
});

TTable

The data shape of the table being queried.

optional explain: boolean

Defined in: define/table/types/query.ts:62

If true, returns the query plan instead of the results.


optional fetch: string[]

Defined in: define/table/types/query.ts:54

An array of fields to fetch (expand related records).


optional from: string | RecordId<string>

Defined in: define/table/types/query.ts:36

The table or record ID to select from. Defaults to the model’s table.


optional groupBy: (string | keyof TTable)[]

Defined in: define/table/types/query.ts:46

An array of fields to group the results by.


optional limit: number

Defined in: define/table/types/query.ts:50

The maximum number of records to return.


optional only: boolean

Defined in: define/table/types/query.ts:38

If true, returns only the first record from the result set.


optional orderBy: OrderByClause[]

Defined in: define/table/types/query.ts:48

An array of OrderByClause objects to sort the results.


optional parallel: boolean

Defined in: define/table/types/query.ts:58

If true, runs the query in parallel with other queries.


optional select: (string | keyof TTable)[]

Defined in: define/table/types/query.ts:34

An array of fields to select. If omitted, all fields (*) are selected.


optional split: (string | keyof TTable)[]

Defined in: define/table/types/query.ts:44

An array of fields to split the results by.


optional start: number

Defined in: define/table/types/query.ts:52

The starting record number.


optional tempfiles: boolean

Defined in: define/table/types/query.ts:60

If true, enables temporary file usage for the query.


optional timeout: string

Defined in: define/table/types/query.ts:56

The timeout for the query, specified in a duration string (e.g. “1m”).


optional vars: Record<string, unknown>

Defined in: define/table/types/query.ts:64

An object of variables to bind to the query.


optional where: string

Defined in: define/table/types/query.ts:42

The WHERE clause for the query.


optional with: { indexes: string[]; } | { noIndex: true; }

Defined in: define/table/types/query.ts:40

The WITH clause for the query, specifying index usage.