4

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
  • which field hast to be in model bar it can be id or any other column you have in model bar ?? Commented Oct 14, 2020 at 8:15

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.