Skip to content

postgrelize / SelectOptions

Type Alias: SelectOptions ​

SelectOptions = object

Defined in: src/model/select-options.ts:76

Options that shape a SELECT statement, shared by finders and copyTo.

Finders extend this with flags such as raw and include (FindOptions).

Example ​

ts
const opts: SelectOptions = {
  attributes: ['status', [fn('count', col('id')), 'n']],
  group: ['status'],
  having: { n: { [Op.gt]: 1 } },
  order: [['status', 'DESC']],
  limit: 20,
  offset: 40,
};

Properties ​

attributes? ​

optional attributes?: FindAttributeOptions

Defined in: src/model/select-options.ts:80

Selected attributes. All attributes when omitted.


distinctOn? ​

optional distinctOn?: readonly unknown[]

Defined in: src/model/select-options.ts:104

postgrelize extension

SELECT DISTINCT ON (...): attributes or expressions. PostgreSQL extension.


group? ​

optional group?: unknown

Defined in: src/model/select-options.ts:84

GROUP BY attributes or expressions.


having? ​

optional having?: unknown

Defined in: src/model/select-options.ts:86

HAVING condition.


limit? ​

optional limit?: number | null

Defined in: src/model/select-options.ts:88

Maximum number of rows; null or undefined for no limit.


lock? ​

optional lock?: LockOption

Defined in: src/model/select-options.ts:92

Row lock (FOR UPDATE etc.); requires a transaction.


noWait? ​

optional noWait?: boolean

Defined in: src/model/select-options.ts:99

postgrelize extension

Add NOWAIT to the row lock so the query fails instead of waiting; only with lock. PostgreSQL extension.


offset? ​

optional offset?: number | null

Defined in: src/model/select-options.ts:90

Number of rows to skip; null or undefined to skip none.


order? ​

optional order?: Order | readonly OrderItem[]

Defined in: src/model/select-options.ts:82

Sort order: attribute names, [attribute, 'ASC' | 'DESC'] pairs or expressions.


sample? ​

optional sample?: TableSampleOptions

Defined in: src/model/select-options.ts:115

postgrelize extension

Read only a random sample of the model table (TABLESAMPLE). PostgreSQL extension.


skipLocked? ​

optional skipLocked?: boolean

Defined in: src/model/select-options.ts:94

Add SKIP LOCKED to the row lock; only with lock.


where? ​

optional where?: unknown

Defined in: src/model/select-options.ts:78

Filter; finders type this as WhereOptions.


withTies? ​

optional withTies?: boolean

Defined in: src/model/select-options.ts:110

postgrelize extension

FETCH FIRST limit ROWS WITH TIES instead of LIMIT: also returns the rows that tie with the last one on the order columns. Needs limit and order. PostgreSQL extension.

Released under the MIT License.