const where = {
office_no: 1999,
status: 'APPLY,
[Op.and]: [
Sequelize.literal(`${property_master_no} member of (request_json->'$.property[*].property_master_no')`)
]
}
if (document_no) {
where['no'] = {
[Op.not]: document_no
}
}
我想在
if
中制作const where
。
抱歉。我不知道。
通过使用组合扩展和三元运算符确实可以实现
const where = {
office_no: 1999,
status: 'APPLY,
[Op.and]: [
Sequelize.literal(`${property_master_no} member of (request_json->'$.property[*].property_master_no')`)
],
...(document_no ? { 'no': { [Op.not]: document_no } } : {})
}