Sequelize 查找软删除的行 [英] Sequelize find soft deleted rows
本文介绍了Sequelize 查找软删除的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从数据库中获取一些软删除的行和一些没有的行,但这对我不起作用.
I'm trying to get some rows from database that are soft deleted AND some that are not, but it's not working for me.
Model.findAll({
'where': {
cond: 'xxx'
},
include: [Model2],
paranoid: false
}).then(function (rows) {
// do something
}).catch(function (err) {
// do something
});
我该怎么做?
推荐答案
您的查询应包括已被软删除的 Model
实例,但不包括 实例被软删除的模型 2
.
The query you have should include instances of Model
that have been soft-deleted, but won't include instances of Model2
that are soft-deleted.
要获得软删除的 Model2
实例,您还需要 include
中的 paranoid: false
选项:
To get the soft-deleted Model2
instances, you'll also need the paranoid: false
option within the include
:
Model.findAll({
'where': {
cond: 'xxx'
},
include: [{
model: Model2,
paranoid: false
}],
paranoid: false
}).then(function (rows) {
// do something
}).catch(function (err) {
// do something
});
这似乎不在文档中,但我试过了,它奏效了.
This doesn't seem to be in the documentation, but I tried it and it worked.
这篇关于Sequelize 查找软删除的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文