不要怂,就是干,撸起袖子干!

Commit b3d28490 by Erik Seliger Committed by GitHub

fix(types): add poolable to count options (#10938)

1 parent e7c86283
......@@ -34,6 +34,15 @@ export interface Logging {
benchmark?: boolean;
}
export interface Poolable {
/**
* Force the query to use the write pool, regardless of the query type.
*
* @default false
*/
useMaster?: boolean;
}
export interface Transactionable {
/**
* Transaction to run query under
......@@ -551,7 +560,7 @@ export interface NonNullFindOptions extends FindOptions {
/**
* Options for Model.count method
*/
export interface CountOptions extends Logging, Transactionable, Filterable, Projectable, Paranoid {
export interface CountOptions extends Logging, Transactionable, Filterable, Projectable, Paranoid, Poolable {
/**
* Include options. See `find` for details
*/
......
import { DataType } from './data-types';
import { Logging, Model, ModelAttributeColumnOptions, ModelAttributes, Transactionable, WhereOptions, Filterable } from './model';
import { Logging, Model, ModelAttributeColumnOptions, ModelAttributes, Transactionable, WhereOptions, Filterable, Poolable } from './model';
import { Promise } from './promise';
import QueryTypes = require('./query-types');
import { Sequelize, RetryOptions } from './sequelize';
......@@ -10,7 +10,7 @@ type BindOrReplacements = { [key: string]: unknown } | unknown[];
/**
* Interface for query options
*/
export interface QueryOptions extends Logging, Transactionable {
export interface QueryOptions extends Logging, Transactionable, Poolable {
/**
* If true, sequelize will not try to format the results of the query, or build an instance of a model from
* the result
......@@ -51,13 +51,6 @@ export interface QueryOptions extends Logging, Transactionable {
bind?: BindOrReplacements;
/**
* Force the query to use the write pool, regardless of the query type.
*
* @default false
*/
useMaster?: boolean;
/**
* A sequelize instance used to build the return instance
*/
instance?: Model;
......
import { Model, Promise } from 'sequelize';
import { Model, Promise, Op } from 'sequelize';
class MyModel extends Model {}
const grouped: Promise<{ [key: string]: number }> = MyModel.count({ group: 'tag' });
const counted: Promise<number> = MyModel.count();
const countedDistinct: Promise<number> = MyModel.count({ col: 'tag', distinct: true });
\ No newline at end of file
const countedDistinct: Promise<number> = MyModel.count({ col: 'tag', distinct: true });
const countedDistinctOnReader: Promise<number> = MyModel.count({ where: { updatedAt: { [Op.gte]: new Date() } }, useMaster: false })
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!