Home > Net >  NPM Sequelize, where: [list]
NPM Sequelize, where: [list]

Time:04-27

Hey I am very new to working with sequelize ORM and I wasn't able to find out if I can use where in a findAll() with a list.

So here accountIds is a list of ids and the table I am searching I want to get any row where the accountId is in accountIds. Is this the correct way to do this in sequelize?

.findAll({
  where: {
    accountId: [accountIds]
  }
})

CodePudding user response:

make sure your accountIds is an array.

const Op = Sequelize.Op;
 definedTable.findAll({
 where: {
      zip_code: {
        $in: accountIds
      }})

Go HERE for more complex quires

  • Related