Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

272
Views
Waterline ORM (sails.js) "where or" - effiency

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!