Home > Blockchain >  expressJS nested sequelize ORM query
expressJS nested sequelize ORM query

Time:12-25

My schema goes like this accounts -> leads -> enquires I want to query using accountId to get only all relavent enquires as list which are linked to leads.

Thanks in advnace .

CodePudding user response:

You have to use the include option.

const accountId = 123;

const enquiries = await Enquiry.findAll({
  include: [
    {
      model: Lead,
      where: { accountId },
    },
  ],
});
  • Related