waterline query with multiple 'or' clauses

937 views
Skip to first unread message

Jerry Dalum

unread,
Feb 6, 2015, 5:42:13 PM2/6/15
to sai...@googlegroups.com
I am trying to write a sails waterline query with two 'or' clauses where both have to be true, but it seems to not work. This is the query that I have tried but it pulls only when one of the 'or' clauses meets its criteria, which I am trying to return only when both 'or' clauses' criteria are met, not one. Is this a bug or is there another way to do this?

 Employee.find()
.where({
  or: [
    {locationId: employee.currentLocation.id},
    {facilityId: employee.facilityId, userName:employee.userName,accountOwner: true}
]})
.where({
  or:[
    {employeeId: { startsWith: params.search.value }},
    {fullName: { startsWith: params.search.value }},
    {street: { startsWith: params.search.value }},                              
    {emailAddress: { startsWith: params.search.value }},
    {employeeType: { startsWith: params.search.value }},
    {status: { startsWith: params.search.value }}
]});
    

Ambroise Dhenain

unread,
Feb 6, 2015, 5:49:55 PM2/6/15
to Jerry Dalum, sai...@googlegroups.com
If you want two "or" clauses to be true, why not use an "and" close then?
--
Cordialement,

M. Ambroise Dhenain.

Jerry Dalum

unread,
Feb 6, 2015, 5:55:05 PM2/6/15
to sai...@googlegroups.com, grd...@gmail.com
can you point me to the documentation on how to use the and clause with waterline?

Ambroise Dhenain

unread,
Feb 6, 2015, 5:57:17 PM2/6/15
to Jerry Dalum, sai...@googlegroups.com
I guess the "and" clause is the default one, take a look at this.

I don't use waterline myself, so I cannot help you out myself. 

Jerry Dalum

unread,
Feb 6, 2015, 6:01:50 PM2/6/15
to sai...@googlegroups.com, grd...@gmail.com
yeah, i saw that one. that is why i put the two or clauses in their own 'where' clause as my example shows, but still no dice.

Andrew Lewman

unread,
Dec 27, 2018, 8:55:38 AM12/27/18
to sails.js
did you find how to do that???

суббота, 7 февраля 2015 г., 1:42:13 UTC+3 пользователь Jerry Dalum написал:
Reply all
Reply to author
Forward
0 new messages