Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 638b13b2
authored
Apr 14, 2019
by
Mirko Jotic
Committed by
Sushant
Apr 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(typings): model.count with group by (#10763)
1 parent
7a6c60d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
types/lib/model.d.ts
types/test/count.ts
types/lib/model.d.ts
View file @
638b13b
...
@@ -527,6 +527,18 @@ export interface CountOptions extends Logging, Transactionable, Filterable, Proj
...
@@ -527,6 +527,18 @@ export interface CountOptions extends Logging, Transactionable, Filterable, Proj
col
?:
string
;
col
?:
string
;
}
}
/**
* Options for Model.count when GROUP BY is used
*/
export
interface
CountWithOptions
extends
CountOptions
{
/**
* GROUP BY in sql
* Used in conjunction with `attributes`.
* @see Projectable
*/
group
:
GroupOption
;
}
export
interface
FindAndCountOptions
extends
CountOptions
,
FindOptions
{}
export
interface
FindAndCountOptions
extends
CountOptions
,
FindOptions
{}
/**
/**
...
@@ -1744,6 +1756,11 @@ export abstract class Model<T = any, T2 = any> extends Hooks {
...
@@ -1744,6 +1756,11 @@ export abstract class Model<T = any, T2 = any> extends Hooks {
):
Promise
<
T
>
;
):
Promise
<
T
>
;
/**
/**
* Count number of records if group by is used
*/
public
static
count
(
options
:
CountWithOptions
):
Promise
<
{
[
key
:
string
]:
number
}
>
;
/**
* Count the number of records matching the provided where clause.
* Count the number of records matching the provided where clause.
*
*
* If you provide an `include` option, the number of matching associations will be counted instead.
* If you provide an `include` option, the number of matching associations will be counted instead.
...
...
types/test/count.ts
0 → 100644
View file @
638b13b
import
{
Model
,
Promise
}
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
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment