-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
filter param generator helper #53
Comments
Why do we need any such library if we can create a query builder for current implementation? And there will not be any breaking changes. |
To clarify: If i had mongo-like query api that would much simpler for me |
@Bnaya did you make any progress on the react-admin data provider? |
I wrote something sketchy, |
@Bnaya @esistgut import { RequestQueryBuilder } from '@nestjsx/request-query';
const qb = new RequestQueryBuilder();
const queryString = qb
.select(['id', 'name', 'email'])
.setFilter({ field: 'name', operator: 'eq', value: 'John' })
.setOr({ field: 'email', operator: 'cont', value: 'john' })
.setJoin({ field: 'company', select: ['name'] })
.setJoin({ field: 'profile' })
.sortBy({ field: 'id', order: 'DESC' })
.setLimit(20)
.setPage(3)
.resetCache()
.query(); Also, it will be possible to set names map to each of existing query param, .e.g: import { RequestQueryBuilder } from '@nestjsx/request-query';
RequestQueryBuilder.setOptions({
delim: '||',
delimStr: ',',
paramNamesMap: {
fields: ['fields', 'select'],
filter: ['filter[]', 'filter'],
or: ['or[]', 'or'],
join: ['join[]', 'join'],
sort: ['sort[]', 'sort'],
limit: ['per_page', 'limit'],
offset: ['offset'],
page: ['page'],
cache: ['cache'],
},
}) ...and to change to whatever you want. And of coucre this must be done on the backend side as well. I'll provide more details on that in the future. So guys, please let me know what you think about that. It's 100% done, 100% covered by tests, but not published yet. Cheers! |
Amazing, thank you!! |
Is there any ready-made lib that will take query object, in a syntax similar to, say mongo query,
![Screen Shot 2019-03-29 at 18 22 25](https://user-images.githubusercontent.com/1304862/55243143-ab385300-524f-11e9-9531-c4d7154f4863.png)
And will give the appropriate
filter
for it?The syntax is very hard to write
The text was updated successfully, but these errors were encountered: