Skip to content

postgrelize / CountOptions

Type Alias: CountOptions<T> ​

CountOptions<T> = QueryOptionsBase & Readonly<{ col?: string; distinct?: boolean; group?: string | readonly string[]; hooks?: boolean; include?: IncludeOption; paranoid?: boolean; sample?: TableSampleOptions; where?: WhereOptions<T>; }> & CteFindOptions

Defined in: src/model/find-options.ts:116

Options of count.

Includes joins and CTE options; count fires beforeCount hooks.

Type Parameters ​

T ​

T = Values

See ​

Model.count

Example ​

ts
const total = await Post.count({ where: { published: true }, distinct: true, col: 'authorId' });
const opts: CountOptions<Post> = { group: 'authorId' };
const perAuthor = await Post.count(opts); // [{ authorId, count }, ...]

Released under the MIT License.