Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Search Modifier “OR” in Sails.js using Waterline Adapter for Mongo #6353

Closed
insidesmart opened this issue Sep 14, 2013 · 9 comments

Comments

@insidesmart
Copy link

The below code is written to fetch records containing "sometext" in either "name" or "description". This seems to be not working.

Can someone provide a correct way to implement "OR" searches

Side Note: "AND" function works. "OR" function is not working. sailsjs & sails-mongo version 0.94 is used.

Model.find({
     where: {
      or: [
       {name: {contains: req.param('sometext')}},
       {description: {contains: req.param('sometext')}}
      ]
     }, limit: 15, skip: 0, sort: 'name ASC'
    }, callback)

@particlebanana
Copy link
Contributor

Looks like there is an issue with or queries not expanding criteria recursively. I can confirm this issue exists in both Mongo and Disk and isn't tested in the waterline-adapter-tests.

@insidesmart
Copy link
Author

Thanks for the confirmation of the bug.

@vpegado
Copy link

vpegado commented Oct 16, 2013

This works with sails-disk 0.9.1 but not with sails-mongo 0.9.5

@alphacentory
Copy link

is there any updates on this bug fix? I can write this using multiple finds for now to mimic the functionality, just am wondering where the bug fix is, and maybe if I can contribute in any way.

@jonathanwiesel
Copy link

Any updates about this? It's has been 2 months...

@jakeopie
Copy link

Yeah, any updates?

@vpegado
Copy link

vpegado commented Nov 14, 2013

The real issue is located here: https://github.com/balderdashy/sails-mongo/issues/59

@vpegado
Copy link

vpegado commented Nov 15, 2013

I worked it out last night and submitted the solution here: balderdashy/sails-mongo#70

@polastre
Copy link

This nasty OR bug exists in https://github.com/balderdashy/sails-postgresql in the 0.9.x branch (0.9.7 release). It isn't expanding the nested OR statement.

@johnabrams7 johnabrams7 transferred this issue from balderdashy/waterline May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants