Skip to content

Commit b8809b3

Browse files
fixes and closes #150
1 parent 347989d commit b8809b3

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

lib/interfaces/ICountOptions.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {AnyWhereOptions, LoggingOptions, SearchPathOptions} from 'sequelize';
2+
import {IIncludeOptions} from './IIncludeOptions';
3+
import {Model} from '../models/Model';
4+
5+
export interface ICountOptions extends LoggingOptions, SearchPathOptions {
6+
7+
/**
8+
* A hash of search attributes.
9+
*/
10+
where?: AnyWhereOptions | string[];
11+
12+
/**
13+
* Include options. See `find` for details
14+
*/
15+
include?: Array<typeof Model | IIncludeOptions>;
16+
17+
/**
18+
* Apply COUNT(DISTINCT(col))
19+
*/
20+
distinct?: boolean;
21+
22+
/**
23+
* Used in conjustion with `group`
24+
*/
25+
attributes?: Array<string | [string, string]>;
26+
27+
/**
28+
* For creating complex counts. Will return multiple rows as needed.
29+
*
30+
* TODO: Check?
31+
*/
32+
group?: Object;
33+
}

lib/models/Model.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import {
88
AggregateOptions, InstanceIncrementDecrementOptions, DropOptions,
99
InstanceUpdateOptions, InstanceDestroyOptions, InstanceRestoreOptions,
1010
SchemaOptions, GetTableNameOptions, AddScopeOptions, ScopeOptions,
11-
WhereOptions, CountOptions, ValidationError, DefineAttributes
11+
WhereOptions, ValidationError, DefineAttributes
1212
} from 'sequelize';
1313
import {IAssociationActionOptions} from "../interfaces/IAssociationActionOptions";
1414
import {IBuildOptions} from "../interfaces/IBuildOptions";
1515
import {ICreateOptions} from "../interfaces/ICreateOptions";
1616
import {IFindOrInitializeOptions} from "../interfaces/IFindOrInitializeOptions";
1717
import {IFindCreateFindOptions} from "../interfaces/IFindCreateFindOptions";
18+
import {ICountOptions} from '../interfaces/ICountOptions';
1819

1920
/* tslint:disable:member-ordering */
2021
/* tslint:disable:array-type */
@@ -232,7 +233,7 @@ export declare class Model<T> extends Hooks {
232233
*
233234
* If you provide an `include` option, the number of matching associations will be counted instead.
234235
*/
235-
static count(options?: CountOptions): Promise<number>;
236+
static count(options?: ICountOptions): Promise<number>;
236237

237238
/**
238239
* Find all the rows matching your query, within a specified offset / limit, and get the total number of

0 commit comments

Comments
 (0)