当前位置:网站首页>Serialize operator
Serialize operator
2022-07-25 23:21:00 【Intern Sen】
1 sequelize The operator
const {
Op } = require("sequelize");
Post.findAll({
where: {
[Op.and]: [{
a: 5 }, {
b: 6 }], // (a = 5) AND (b = 6)
[Op.or]: [{
a: 5 }, {
b: 6 }], // (a = 5) OR (b = 6)
Some attribute : {
// basic
[Op.eq]: 3, // = 3
[Op.ne]: 20, // != 20
[Op.is]: null, // IS NULL
[Op.not]: true, // IS NOT TRUE
[Op.or]: [5, 6], // (someAttribute = 5) OR (someAttribute = 6)
// Use dialect specific column identifiers ( Used in the following example PG):
[Op.col]: 'user.organization_id', // = "user"."organization_id"
// Number comparison
[Op.gt]: 6, // > 6
[Op.gte]: 6, // >= 6
[Op.lt]: 10, // < 10
[Op.lte]: 10, // <= 10
[Op.between]: [6, 10], // BETWEEN 6 AND 10
[Op.notBetween]: [11, 15], // NOT BETWEEN 11 AND 15
// Other operators
[Op.all]: sequelize.literal('SELECT 1'), // > ALL (SELECT 1)
[Op.in]: [1, 2], // IN [1, 2]
[Op.notIn]: [1, 2], // NOT IN [1, 2]
[Op.like]: '%hat', // LIKE '%hat'
[Op.notLike]: '%hat', // NOT LIKE '%hat'
[Op.startsWith]: 'hat', // LIKE 'hat%'
[Op.endsWith]: 'hat', // LIKE '%hat'
[Op.substring]: 'hat', // LIKE '%hat%'
[Op.iLike]: '%hat', // ILIKE '%hat' ( Case insensitive ) ( only PG)
[Op.notILike]: '%hat', // NOT ILIKE '%hat' ( only PG)
[Op.regexp]: '^[h|a|t]', // REGEXP/~ '^[h|a|t]' ( only MySQL/PG)
[Op.notRegexp]: '^[h|a|t]', // NOT REGEXP/!~ '^[h|a|t]' ( only MySQL/PG)
[Op.iRegexp]: '^[h|a|t]', // ~* '^[h|a|t]' ( only PG)
[Op.notIRegexp]: '^[h|a|t]', // !~* '^[h|a|t]' ( only PG)
[Op.any]: [2, 3], // ANY ARRAY[2, 3]::INTEGER ( only PG)
[Op.match]: Sequelize.fn('to_tsquery', 'fat & rat') // Match text search string 'fat' and 'rat' ( only PG)
// stay Postgres in , Op.like/Op.iLike/Op.notLike Can combine Op.any Use :
[Op.like]: {
[Op.any]: ['cat', 'hat'] } // LIKE ANY ARRAY['cat', 'hat']
}
}
});
2 Op.and
const users = await User.findAll({
where: {
[Op.and]:[
{
name: ' Xiao Xu '},
{
age: 18 }
]
}
})
// select * from User where name = ' Xiao Xu ' and age = 18;
3 Op.or
const users = await User.findAll({
where: {
[Op.or]:[
{
age: 18 },
{
age: 19 }
]
}
})
const users = await User.findAll({
where: {
age: {
[Op.or]:[18,19]
}
}
})
// select * from User where age = 18 or age = 19;
4 Op.in
const users = User.findAll({
where: {
id: {
[Op.in]:[1,2,3]
}
}
})
// Upper and lower equivalence
const users = User.findAll({
where: {
id:[1,2,3]
}
})
边栏推荐
- idea设置get、set模板解决boolean类型字段的命名问题
- CSV generated by PHP cannot completely display the number with leading 0
- File contains vulnerability
- Serialize common default values and column parameters
- How to set pseudo static for WordPress fixed links
- Network Security Learning notes-1 file upload
- Summary of kotlin common knowledge points
- Source code of YY music wechat applet imitating Netease cloud music
- 5 ROS仿真建模(3- rviz+gazebo+控制仿真机器人)
- Cuteone: a onedrive multi network disk mounting program / with member / synchronization and other functions
猜你喜欢

Solve the problem phpstudy failed to import the database

File contains vulnerability

Discuz magazine / news report template (jeavi_line) utf8 GBK / DZ template download

XxE & XML external entity injection utilization and bypass

Zero crossing position search of discrete data (array)

Analysis of the influence of ESM direction finding error on positioning error

@Import

Single model common sense reasoning first surpasses human beings! HFL summit openbookqa challenge

Family relationship calculator wechat applet source code

The VM session was closed before any attempt to power it on
随机推荐
Tips for using (1)
Drive board network cable directly connected to computer shared network configuration
Call Gaode map -- address is converted into longitude and latitude
CTS test method "suggestions collection"
PCL basic operation Encyclopedia
Redis过期键的删除策略[通俗易懂]
日期类的实现
Simulink学习笔记(三)——Simulink自动代码生成(二)「建议收藏」
Unity uses macros
Check code generation
Several commonly used traversal methods
Ffmpeg first learning (only for coding)
Enabling partners, how can Amazon cloud technology "get on the horse and get a ride"?
XXE&XML-外部实体注入-利用和绕过
Bind class style and bind style style
idea设置get、set模板解决boolean类型字段的命名问题
AI chief architect 12 AICA industrial landing analysis under the industrial production process optimization scenario
学习探索-3d轮播卡片
Hj9 extract non duplicate integers
[interface performance optimization] reasons for index failure and how to optimize SQL