I am using Waterline ORM (sails.js), and the query "where or".
I have a query with a multiple 'or' in the 'where' section, that checks if any of 2 specific fields are equal to a value in an array
and should return that item,
lets say the array is var array = ["Jack", "Kyle","Stan", "Randy"]
and the fields are 'name' and 'nickName' , and the query runs -
where
'name' or 'nickName' equals "Jack"
or
'name' or 'nickName' equals "Kyle"
or
'name' or 'nickName' equals "Stan"
or
'name' or 'nickName' equals "Randy"
Now the query runs extremely slow, and I wish to make it faster.
is there a way to make the query faster using sails.js? by the waterline ORM?
await Users.find({
where: {
or: [
{ name: ["Jack", "Kyle","Stan", "Randy"] },
{ nickName: ["Jack", "Kyle","Stan", "Randy"] },
]
}
})
or : modifier to match any of the nested rule sets you specify as an array of query pairs.
{ name: ["Jack", "Kyle","Stan", "Randy"] }
This is more or less equivalent to "IN" queries in SQL
More about Waterline query language