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 b3d28490
authored
May 12, 2019
by
Erik Seliger
Committed by
GitHub
May 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(types): add poolable to count options (#10938)
1 parent
e7c86283
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
types/lib/model.d.ts
types/lib/query-interface.d.ts
types/test/count.ts
types/lib/model.d.ts
View file @
b3d2849
...
...
@@ -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
*/
...
...
types/lib/query-interface.d.ts
View file @
b3d2849
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
;
...
...
types/test/count.ts
View file @
b3d2849
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
})
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