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 ba5192ce
authored
Apr 27, 2019
by
Simon Schick
Committed by
GitHub
Apr 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(typings): add some missing operators (#10846)
1 parent
5412adea
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
types/lib/model.d.ts
types/lib/operators.d.ts
types/test/where.ts
types/lib/model.d.ts
View file @
ba5192c
...
@@ -125,9 +125,11 @@ export interface AnyOperator {
...
@@ -125,9 +125,11 @@ export interface AnyOperator {
/** Undocumented? */
/** Undocumented? */
export
interface
AllOperator
{
export
interface
AllOperator
{
[
Op
.
all
]:
(
string
|
number
)[];
[
Op
.
all
]:
(
string
|
number
|
Date
|
Literal
)[];
}
}
export
type
Rangable
=
[
number
,
number
]
|
[
Date
,
Date
]
|
Literal
;
/**
/**
* Operators that can be used in WhereOptions
* Operators that can be used in WhereOptions
*
*
...
@@ -193,21 +195,21 @@ export interface WhereOperators {
...
@@ -193,21 +195,21 @@ export interface WhereOperators {
*
*
* Example: `[Op.overlap]: [1, 2]` becomes `&& [1, 2]`
* Example: `[Op.overlap]: [1, 2]` becomes `&& [1, 2]`
*/
*/
[
Op
.
overlap
]?:
[
number
,
number
]
|
Literal
;
[
Op
.
overlap
]?:
Rangable
;
/**
/**
* PG array contains operator
* PG array contains operator
*
*
* Example: `[Op.contains]: [1, 2]` becomes `@> [1, 2]`
* Example: `[Op.contains]: [1, 2]` becomes `@> [1, 2]`
*/
*/
[
Op
.
contains
]?:
[
number
,
number
]
|
[
Date
,
Date
]
|
Literal
;
[
Op
.
contains
]?:
Rangable
;
/**
/**
* PG array contained by operator
* PG array contained by operator
*
*
* Example: `[Op.contained]: [1, 2]` becomes `<@ [1, 2]`
* Example: `[Op.contained]: [1, 2]` becomes `<@ [1, 2]`
*/
*/
[
Op
.
contained
]?:
[
number
,
number
]
|
[
Date
,
Date
]
|
Literal
;
[
Op
.
contained
]?:
Rangable
;
/** Example: `[Op.gt]: 6,` becomes `> 6` */
/** Example: `[Op.gt]: 6,` becomes `> 6` */
[
Op
.
gt
]?:
number
|
string
|
Date
|
Literal
;
[
Op
.
gt
]?:
number
|
string
|
Date
|
Literal
;
...
@@ -273,6 +275,35 @@ export interface WhereOperators {
...
@@ -273,6 +275,35 @@ export interface WhereOperators {
* Example: `[Op.notIRegexp]: '^[h|a|t]'` becomes `!~* '^[h|a|t]'`
* Example: `[Op.notIRegexp]: '^[h|a|t]'` becomes `!~* '^[h|a|t]'`
*/
*/
[
Op
.
notIRegexp
]?:
string
;
[
Op
.
notIRegexp
]?:
string
;
/**
* PG only
*
* Forces the operator to be strictly left eg. `<< [a, b)`
*/
[
Op
.
strictLeft
]?:
Rangable
;
/**
* PG only
*
* Forces the operator to be strictly right eg. `>> [a, b)`
*/
[
Op
.
strictRight
]?:
Rangable
;
/**
* PG only
*
* Forces the operator to not extend the left eg. `&> [1, 2)`
*/
[
Op
.
noExtendLeft
]?:
Rangable
;
/**
* PG only
*
* Forces the operator to not extend the left eg. `&< [1, 2)`
*/
[
Op
.
noExtendRight
]?:
Rangable
;
}
}
/** Example: `[Op.or]: [{a: 5}, {a: 6}]` becomes `(a = 5 OR a = 6)` */
/** Example: `[Op.or]: [{a: 5}, {a: 6}]` becomes `(a = 5 OR a = 6)` */
...
...
types/lib/operators.d.ts
View file @
ba5192c
...
@@ -39,5 +39,6 @@ declare const Op: {
...
@@ -39,5 +39,6 @@ declare const Op: {
readonly
strictLeft
:
unique
symbol
;
readonly
strictLeft
:
unique
symbol
;
readonly
strictRight
:
unique
symbol
;
readonly
strictRight
:
unique
symbol
;
readonly
substring
:
unique
symbol
;
readonly
substring
:
unique
symbol
;
readonly
values
:
unique
symbol
;
};
};
export
=
Op
;
export
=
Op
;
types/test/where.ts
View file @
ba5192c
...
@@ -170,7 +170,6 @@ MyModel.findAll({ lock: { level: Transaction.LOCK.KEY_SHARE, of: MyModel} }).the
...
@@ -170,7 +170,6 @@ MyModel.findAll({ lock: { level: Transaction.LOCK.KEY_SHARE, of: MyModel} }).the
MyModel
.
findAll
({
MyModel
.
findAll
({
where
:
{
where
:
{
// tslint:disable-next-line:no-object-literal-type-assertion
id
:
{
id
:
{
// casting here to check a missing operator is not accepted as field name
// casting here to check a missing operator is not accepted as field name
[
Op
.
and
]:
{
a
:
5
},
// AND (a = 5)
[
Op
.
and
]:
{
a
:
5
},
// AND (a = 5)
...
@@ -192,6 +191,12 @@ MyModel.findAll({
...
@@ -192,6 +191,12 @@ MyModel.findAll({
[
Op
.
contains
]:
[
1
,
2
],
// @> [1, 2] (PG array contains operator)
[
Op
.
contains
]:
[
1
,
2
],
// @> [1, 2] (PG array contains operator)
[
Op
.
contained
]:
[
1
,
2
],
// <@ [1, 2] (PG array contained by operator)
[
Op
.
contained
]:
[
1
,
2
],
// <@ [1, 2] (PG array contained by operator)
[
Op
.
any
]:
[
2
,
3
],
// ANY ARRAY[2, 3]::INTEGER (PG only)
[
Op
.
any
]:
[
2
,
3
],
// ANY ARRAY[2, 3]::INTEGER (PG only)
[
Op
.
adjacent
]:
[
1
,
2
],
[
Op
.
strictLeft
]:
[
1
,
2
],
[
Op
.
strictRight
]:
[
1
,
2
],
[
Op
.
noExtendLeft
]:
[
1
,
2
],
[
Op
.
noExtendRight
]:
[
1
,
2
],
[
Op
.
values
]:
[
1
,
2
],
}
as
WhereOperators
,
}
as
WhereOperators
,
status
:
{
status
:
{
[
Op
.
not
]:
false
,
// status NOT FALSE
[
Op
.
not
]:
false
,
// status NOT 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