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

Support comparison operators with a=b query format #15

Closed
wolraich opened this issue Mar 3, 2017 · 6 comments
Closed

Support comparison operators with a=b query format #15

wolraich opened this issue Mar 3, 2017 · 6 comments

Comments

@wolraich
Copy link

wolraich commented Mar 3, 2017

Angular.js resources generate query strings with the standard a=p format. So User.query({ age: 21 }) would generate GET: /user/?age=21. That's a problem if we want to use query-to-mongo filters with any operator other than =. For instance, User.query({ age: '>21' }) would generate GET: /user/?age=%3E21, which query-to-mongo doesn't like. It would be great if query-to-mongo would handle age=%3E21 and other comparison operators the same way it handles age%3E21.

@pbatey
Copy link
Owner

pbatey commented Mar 4, 2017

Can you privide a code example of the string to pass in and the expected resilts? Or a reference to the angular.js subsection you are referring to? (I'm haven't used angular.js resources)

@wolraich
Copy link
Author

I apologize for the delayed response. Angular resources are described here: https://docs.angularjs.org/api/ngResource/service/$resource. Fundamentally, the issue is that angular doesn't let you specify url query params with a>b format, only a=b. So it would be great if query-to-mongo accepted a=>b as an alternative to a>b. Does that make sense?

@wolraich
Copy link
Author

wolraich commented Mar 13, 2017

There's also a similar issue with the $exists format. Angular resources won't allow a query like ?a only ?a=

@wolraich
Copy link
Author

Ah, I looked in the code and see that ?a>b= is functionally equivalent to ?a>b. That's an ok workaround, though I still think ?a=>b would be more intuitive and easier to code on the client.

@pbatey
Copy link
Owner

pbatey commented Mar 2, 2018

Sorry for the delay - I see what you were getting at - added the behavior in v0.8.0.

@pbatey
Copy link
Owner

pbatey commented Mar 2, 2018

I've opened issue #18 to address the $exists problem separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants