kevva
kevva

Reputation: 41

Sequelize with postgres - find all where uuid is contained by an array of uuid-s

My model has a primary key of UUID and I am trying to make a query:

const idList = ['70ebc891-cdaf-4547-a88c-264a03c99c8d'];
MyModel.findAll({ where: {
        id: {
          $contained: idList
        } }
      })

But this query does not work, since idList is of type Text[] for postgres.

Is there any way to cast UUID[] to this array in sequelize or is there any other way to handle this?

Postgres error:

ERROR:  operator does not exist: uuid <@ text[] at character 137

Thanks!

Upvotes: 2

Views: 1965

Answers (1)

kevva
kevva

Reputation: 41

Figured it out. Use $in instead.

MyModel.findAll({ where: {
        id: {
          $in: idList
        } }
      })

Upvotes: 2

Related Questions