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

$in query operator not properly supported #140

Closed
alex-all3dp opened this issue Mar 11, 2020 · 5 comments · Fixed by #141
Closed

$in query operator not properly supported #140

alex-all3dp opened this issue Mar 11, 2020 · 5 comments · Fixed by #141

Comments

@alex-all3dp
Copy link
Contributor

alex-all3dp commented Mar 11, 2020

Filter params with the $in operator like:

{ filter: { name: { $in: ['abc, 'def'] } } }

should be passed as is to the feathers client in order to result in query parameters of the format:

/path?name[$in]=abc&name[$in]=def

The flatten function in restClient.js incorrectly translates the input filter incorrectly to the following query:

{ 'name.$in': ['abc', 'def'] }

which results in the query parameters: /path?name.$in[0]=abc&name.$in[1]=def

Simply adding $in to the queryOperators (as stopKeys parameter input) results in the correct query format

{ name: { $in: ['abc', 'def'] } }

which results in the query parameters /path?name[$in][0]=abc&name[$in][1]=def

@alex-all3dp alex-all3dp changed the title $in $in query operator not properly supported Mar 11, 2020
@josx josx closed this as completed in #141 Mar 11, 2020
@josx
Copy link
Owner

josx commented Mar 11, 2020

@alex-all3dp
good catch, can you recheck if the last commit fix this problem.

@josx
Copy link
Owner

josx commented Mar 11, 2020

after you confirmation i will release a new version

@alex-all3dp
Copy link
Contributor Author

Hi @josx,
thank you for the quick response and fix! That commit works.

We just encountered that it would be necessary for us to support even more operators, e.g. from https://github.com/feathersjs-ecosystem/feathers-objection#query-operators. Other users may want to use query operators from other feathers adapters as well.

Would it be possible to make a change that allows to pass custom queryOperators and merge them with the currently hardcoded defaults?

@josx
Copy link
Owner

josx commented Mar 11, 2020

I think it would be great, to have that feature.
Can you make a PR on that? (please also include an example on how to do it in README)

@alex-all3dp
Copy link
Contributor Author

@josx #142

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

Successfully merging a pull request may close this issue.

2 participants