Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Prido's avatar
Level 2

Filter on sequelise relationship

i have a sequelise relationship i am doing like

let user = UserModel.findAll({
inclide: PlanModel
});

Here i want to get all users with their plans but i want only plans for example with status = active. how can i add that extra filter. i want to return null plan when it doesn't meet status active

0 likes
1 reply
frankielee's avatar
let users = UserModel.findAll({
  include: {
    model: PlanModel,
    where: {
      status: "active",
    },
  },
});

V6 Sequelize

Please or to participate in this conversation.