$ open source · GPL-3.0 — need a commercial license? imqueue.com →

query.autoCountQuery() function

The counting counterpart of query.autoQuery(), for the same fields and filter.

Signature:

export function autoCountQuery(model: any, fields?: any, ...merge: (Partial<CountOptions> | undefined)[]): CountOptions;

Parameters

Parameter

Type

Description

model

any

Model to count rows of.

fields

any

(Optional) The same fields map used for the data query.

merge

(Partial<CountOptions> | undefined)[]

The same filter fragments, minus limit and order.

Returns:

CountOptions

Count options ready for Model.count().

Remarks

Builds the same query, then drops attributes and counts distinct primary keys instead — distinct matters because the joins autoQuery adds would otherwise multiply a row once per joined record and inflate the total.

Pass it the same fields and filter as the data query, or the two disagree.