当前位置:网站首页>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]
}
})
边栏推荐
- XXE&XML-外部实体注入-利用和绕过
- Simulate and implement common interfaces of string class
- Very simple vsplayaudio online music player plug-in
- Family relationship calculator wechat applet source code
- Anaconda installation tutorial environment variables (how to configure environment variables)
- TS class
- [interface performance optimization] reasons for index failure and how to optimize SQL
- PCL basic operation Encyclopedia
- WordPress removes the website publishing time
- @Autowired注解 required属性
猜你喜欢
![[interface performance optimization] reasons for index failure and how to optimize SQL](/img/b9/64058c823c4497ac36bfb62a101816.jpg)
[interface performance optimization] reasons for index failure and how to optimize SQL

Secure code warrior learning record (IV)

Cuteone: a onedrive multi network disk mounting program / with member / synchronization and other functions

@Import

XXE&XML-外部实体注入-利用和绕过

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

自定义mvc原理

Family relationship calculator wechat applet source code

驱动板网线直连电脑共享网络配置

OASYS system of code audit
随机推荐
Analysis of the influence of ESM direction finding error on positioning error
2021-09-30
The fifth article in the series of radar Fundamentals: the function of radar modulation style
Firewall command simple operation
PHP binary array is sorted by a field in it
MathType安装和解决不能Crtl+V的问题
Data filtering of MATLAB
Week 2: convolutional neural network
Solve the problem phpstudy failed to import the database
ETL tool (data synchronization) II
ASP date function (what if the disk function is incorrect)
Yii2 behavior usage and its calling method
【微信小程序】页面导航
Simulink学习笔记(三)——Simulink自动代码生成(二)「建议收藏」
四旋翼飞行器的飞控实现「建议收藏」
BI 系统中为什么会有很多快照表?
serialization and deserialization
The new UI people help task help PHP source code with a value of 1500 / reward task Tiktok Kwai headline like source code / with three-level distribution can be packaged applet
Expression of directional signal -- complex exponential signal
Longitude and latitude and its transformation with coordinate system