Given that I have a model called Model
with a column called items
which holds an array of strings, how can I query to see whether a string queryString
is in the array or has a similar element in the array?
Example:
items: ["cat", "dog", "bird", "turtle", "doe" ]
queryString = ["%do%","%b"]
Should return:
animalArray = ["dog", "doe", "bird"]
I've attempted this, except it doesn't seem to return anything of value. $in
searches the elements in queryString
but not necessary the elements in items
, so I'm a little stumped on how I can change this up to see if it can check for all combination of elements in items
and queryString
. - or if it's possible at all!
Model.findAll({
where: {
items: { $in: { $iLike: { $any: queryString } } }
}
}).then(function(array){
// Do whatever here with array
})
$iLike
is a special Postgres thing in Sequelize
Thanks!