query for empty array in "include" model field

Viewed 839

Let’s say I have foo and I make it include bar model,
They are many to many relationship.
While bar model contains a column called clients, which is an array in nodejs.

foo.findAll({
    where      : where,
    include    : [{ model: bar}]
})

How should I use foo.findAll to get all data which bar must be an empty array.

1 Answers

You can simply Do it like this I am suggesting this because your question is unclear

foo.findAll({
    where: where,
    include: [{
        model: bar,
        where: { name: { [Op.is]: null } }
    }]
})

above code will return data of model bar where name as no value or the field is null

Related