SelectQueryOptions
Defined in: define/table/types/query.ts:32
Defines the options available for a SELECT
query.
Example
Section titled “Example”// Find all active users, order by name, and fetch their postsconst activeUsers = await User.find({ where: 'isActive = true', orderBy: [{ field: 'name', order: 'ASC' }], fetch: ['posts'], limit: 50});
Type Parameters
Section titled “Type Parameters”TTable
Section titled “TTable”TTable
The data shape of the table being queried.
Properties
Section titled “Properties”explain?
Section titled “explain?”
optional
explain:boolean
Defined in: define/table/types/query.ts:62
If true, returns the query plan instead of the results.
fetch?
Section titled “fetch?”
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.
groupBy?
Section titled “groupBy?”
optional
groupBy: (string
| keyofTTable
)[]
Defined in: define/table/types/query.ts:46
An array of fields to group the results by.
limit?
Section titled “limit?”
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.
orderBy?
Section titled “orderBy?”
optional
orderBy:OrderByClause
[]
Defined in: define/table/types/query.ts:48
An array of OrderByClause
objects to sort the results.
parallel?
Section titled “parallel?”
optional
parallel:boolean
Defined in: define/table/types/query.ts:58
If true, runs the query in parallel with other queries.
select?
Section titled “select?”
optional
select: (string
| keyofTTable
)[]
Defined in: define/table/types/query.ts:34
An array of fields to select. If omitted, all fields (*
) are selected.
split?
Section titled “split?”
optional
split: (string
| keyofTTable
)[]
Defined in: define/table/types/query.ts:44
An array of fields to split the results by.
start?
Section titled “start?”
optional
start:number
Defined in: define/table/types/query.ts:52
The starting record number.
tempfiles?
Section titled “tempfiles?”
optional
tempfiles:boolean
Defined in: define/table/types/query.ts:60
If true, enables temporary file usage for the query.
timeout?
Section titled “timeout?”
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.
where?
Section titled “where?”
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.