I am trying to do something like below:
# job_type: is of type Array of Enum
const profiles = await Profile.findAll({
where: {
job_type: { [Op.in]: ['Contract', 'Permanent'] },
},
});
The above produces an error below
values.map is not a function
The above error kinda makes sense seeing as job_type is an array of enum.
job_type: DataTypes.ARRAY(
DataTypes.ENUM({
values: ['Contract', 'Temp', 'Volunteer', 'Permanent'],
})
),
Stack trace
Trace: TypeError: values.map is not a function
at ARRAY._value (/Users/########/Desktop/####-backend/node_modules/sequelize/lib/dialects/postgres/data-types.js:379:19)
at ARRAY._stringify (/Users/########/Desktop/####-backend/node_modules/sequelize/lib/dialects/postgres/data-types.js:393:29)
at ARRAY.stringify (/Users/########/Desktop/####-backend/node_modules/sequelize/lib/data-types.js:22:19)
at PostgresQueryGenerator.escape (/Users/########/Desktop/####-backend/node_modules/sequelize/lib/dialects/abstract/query-generator.js:702:30)
at /Users/########/Desktop/####-backend/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1908:71
at Array.map (<anonymous>)
at PostgresQueryGenerator._whereParseSingleValueObject (/Users/########/Desktop/####-backend/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1908:52)
at PostgresQueryGenerator.whereItemQuery (/Users/########/Desktop/####-backend/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1728:21)
at /Users/########/Desktop/####-backend/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1649:25
at Array.forEach (<anonymous>)
If anyone comes across a process to filter by enum values, I will appreciate any input.