最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Sequelize find soft deleted rows - Stack Overflow

programmeradmin1浏览0评论

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
});

How can I do it?

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
});

How can I do it?

Share Improve this question asked Sep 18, 2015 at 19:04 kecal909kecal909 1631 gold badge2 silver badges10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 23

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.

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.

发布评论

评论列表(0)

  1. 暂无评论