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

[crud-request] - Set filter conditions as array for RequestQueryBuilder? #131

Closed
chriszrc opened this issue Jun 26, 2019 · 5 comments
Closed
Labels

Comments

@chriszrc
Copy link

For the RequestQueryBuilder, we can pass in select fields as an array:

const queryString = RequestQueryBuilder
  .create()
  .select(['foo', 'bar'])
  .setFilter({ field: 'foo', operator: CondOperator.NOT_NULL })
  .setFilter({ field: 'bar', operator: CondOperator.NOT_NULL })

but filters have to be chained method calls. Was there an architectural reason for this? If not, this might actually be a PR I can make

@michaelyali
Copy link
Member

Actually yeah, there is a code that I will push soon - it will add a method for passing an object of the query params so you'll be free to get rid of chaining. But if you think that you wanna create a PR, I'll be more than happy with that :)

@chriszrc
Copy link
Author

chriszrc commented Jun 26, 2019 via email

@michaelyali
Copy link
Member

@chriszrc I've added a possibility to add params on .create() (https://github.com/nestjsx/crud/wiki/Requests#usage). Hope that helps. Closing this issue for now.

@chriszrc
Copy link
Author

chriszrc commented Jul 2, 2019

Nice! Works great. I did notice that it appears switching to this method that the global config I had setup was no longer respected:

RequestQueryBuilder.setOptions({
       paramNamesMap: {
         filter: ['filter'],
       },
     });

But, I only included that originally because I think I was in between versions, and the backend wasn't accepting filter requests with the "filter[]" param, only "filter", but now I updated everything, and it's all working, so I can just remove this config. But I guess this should still work for users who want to override the param names?

@michaelyali
Copy link
Member

Yes, this definitely works for query params names overriding :)

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

No branches or pull requests

2 participants