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 e3d6795d
authored
Apr 18, 2019
by
Mirko Jotic
Committed by
Sushant
Apr 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(types): adding Literal type to Operators (#10796)
1 parent
d1645f23
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
16 deletions
types/lib/model.d.ts
types/test/where.ts
types/lib/model.d.ts
View file @
e3d6795
...
...
@@ -138,45 +138,45 @@ export interface WhereOperators {
*
* _PG only_
*/
[
Op
.
any
]?:
(
string
|
number
)[]
;
[
Op
.
any
]?:
(
string
|
number
|
Literal
)[]
|
Literal
;
/** Example: `[Op.gte]: 6,` becomes `>= 6` */
[
Op
.
gte
]?:
number
|
string
|
Date
;
[
Op
.
gte
]?:
number
|
string
|
Date
|
Literal
;
/** Example: `[Op.lt]: 10,` becomes `< 10` */
[
Op
.
lt
]?:
number
|
string
|
Date
;
[
Op
.
lt
]?:
number
|
string
|
Date
|
Literal
;
/** Example: `[Op.lte]: 10,` becomes `<= 10` */
[
Op
.
lte
]?:
number
|
string
|
Date
;
[
Op
.
lte
]?:
number
|
string
|
Date
|
Literal
;
/** Example: `[Op.ne]: 20,` becomes `!= 20` */
[
Op
.
ne
]?:
string
|
number
|
WhereOperators
;
[
Op
.
ne
]?:
string
|
number
|
Literal
|
WhereOperators
;
/** Example: `[Op.not]: true,` becomes `IS NOT TRUE` */
[
Op
.
not
]?:
boolean
|
string
|
number
|
WhereOperators
;
[
Op
.
not
]?:
boolean
|
string
|
number
|
Literal
|
WhereOperators
;
/** Example: `[Op.between]: [6, 10],` becomes `BETWEEN 6 AND 10` */
[
Op
.
between
]?:
[
number
,
number
];
/** Example: `[Op.in]: [1, 2],` becomes `IN [1, 2]` */
[
Op
.
in
]?:
(
string
|
number
)[]
|
Literal
;
[
Op
.
in
]?:
(
string
|
number
|
Literal
)[]
|
Literal
;
/** Example: `[Op.notIn]: [1, 2],` becomes `NOT IN [1, 2]` */
[
Op
.
notIn
]?:
(
string
|
number
)[]
|
Literal
;
[
Op
.
notIn
]?:
(
string
|
number
|
Literal
)[]
|
Literal
;
/**
* Examples:
* - `[Op.like]: '%hat',` becomes `LIKE '%hat'`
* - `[Op.like]: { [Op.any]: ['cat', 'hat']}` becomes `LIKE ANY ARRAY['cat', 'hat']`
*/
[
Op
.
like
]?:
string
|
AnyOperator
|
AllOperator
;
[
Op
.
like
]?:
string
|
Literal
|
AnyOperator
|
AllOperator
;
/**
* Examples:
* - `[Op.notLike]: '%hat'` becomes `NOT LIKE '%hat'`
* - `[Op.notLike]: { [Op.any]: ['cat', 'hat']}` becomes `NOT LIKE ANY ARRAY['cat', 'hat']`
*/
[
Op
.
notLike
]?:
string
|
AnyOperator
|
AllOperator
;
[
Op
.
notLike
]?:
string
|
Literal
|
AnyOperator
|
AllOperator
;
/**
* case insensitive PG only
...
...
@@ -185,31 +185,31 @@ export interface WhereOperators {
* - `[Op.iLike]: '%hat'` becomes `ILIKE '%hat'`
* - `[Op.iLike]: { [Op.any]: ['cat', 'hat']}` becomes `ILIKE ANY ARRAY['cat', 'hat']`
*/
[
Op
.
iLike
]?:
string
|
AnyOperator
|
AllOperator
;
[
Op
.
iLike
]?:
string
|
Literal
|
AnyOperator
|
AllOperator
;
/**
* PG array overlap operator
*
* Example: `[Op.overlap]: [1, 2]` becomes `&& [1, 2]`
*/
[
Op
.
overlap
]?:
[
number
,
number
];
[
Op
.
overlap
]?:
[
number
,
number
]
|
Literal
;
/**
* PG array contains operator
*
* Example: `[Op.contains]: [1, 2]` becomes `@> [1, 2]`
*/
[
Op
.
contains
]?:
[
number
,
number
]
|
[
Date
,
Date
];
[
Op
.
contains
]?:
[
number
,
number
]
|
[
Date
,
Date
]
|
Literal
;
/**
* PG array contained by operator
*
* Example: `[Op.contained]: [1, 2]` becomes `<@ [1, 2]`
*/
[
Op
.
contained
]?:
[
number
,
number
]
|
[
Date
,
Date
];
[
Op
.
contained
]?:
[
number
,
number
]
|
[
Date
,
Date
]
|
Literal
;
/** Example: `[Op.gt]: 6,` becomes `> 6` */
[
Op
.
gt
]?:
number
|
string
|
Date
;
[
Op
.
gt
]?:
number
|
string
|
Date
|
Literal
;
/**
* PG only
...
...
@@ -218,7 +218,7 @@ export interface WhereOperators {
* - `[Op.notILike]: '%hat'` becomes `NOT ILIKE '%hat'`
* - `[Op.notLike]: ['cat', 'hat']` becomes `LIKE ANY ARRAY['cat', 'hat']`
*/
[
Op
.
notILike
]?:
string
|
AnyOperator
|
AllOperator
;
[
Op
.
notILike
]?:
string
|
Literal
|
AnyOperator
|
AllOperator
;
/** Example: `[Op.notBetween]: [11, 15],` becomes `NOT BETWEEN 11 AND 15` */
[
Op
.
notBetween
]?:
[
number
,
number
];
...
...
types/test/where.ts
View file @
e3d6795
...
...
@@ -265,3 +265,29 @@ where = whereFn('test', {
MyModel
.
findAll
({
having
:
where
});
where
=
{
[
Op
.
lt
]:
Sequelize
.
literal
(
'SOME_STRING'
)
}
Sequelize
.
where
(
Sequelize
.
cast
(
Sequelize
.
col
(
'SOME_COL'
),
'INTEGER'
),
{
[
Op
.
lt
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
any
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
gte
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
lt
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
lte
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
ne
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
not
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
in
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
notIn
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
like
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
notLike
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
iLike
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
overlap
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
contains
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
contained
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
gt
]:
Sequelize
.
literal
(
'LIT'
),
[
Op
.
notILike
]:
Sequelize
.
literal
(
'LIT'
)
}
)
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