Comments (4)
There must be two types of filtering; server side and client side. For the server side, it's better not to force users using the library to a specific format. So perhaps we can somehow allow users to replace generateFilteringParams
. For the default, I suggest using the recommended format from JSON API specs which is:
?filter[api]=value
So now the interface should look like:
export interface FilteringParam {
value?: any;
api?: string;
}
The api
should include the field and operator. For example, in Django I have something like:
?filter[comment__author__age__gt]=20
For client side, I think we must force some domain specific language. That's why I created three other parameters: field, type, path
although I forgot how I used them due to lack of documentation :. I think the above server side filter will translate to the following client side filter:
query = {
params: {
filtering: [{type: 'gt', path: 'comment.author', field: 'age', value: 20}]
}
}
I agree that the above filtering can be made cleaner and as you suggested elsewhere: allow users to override the operators and define their own ones.
What do you think we should target first? Allowing users to have a custom generateFilteringParams
?
from ngrx-json-api.
true that a lot of flexiblity is needed in this area. After all they just provide a recommendation, not a specification. The generateFilteringParams sounds good. Having the type/operator seems quite common even tough it is not in the official recommendation.
Nevertheless I still hoping a bit for a similar API between client and server side filtering, at least for the typical use cases that come close to the official recommendation. Meaning that client side filtering would translate "filter[comment.author]" to a path "attributes.comment.author". Or maybe both should be supported, a server and client side filtering meachnism and a possiblity to translate the former to the later. Otherwise more work needs to be done in the UI to work with one or the other.
from ngrx-json-api.
Please have a look at #38 and #39 . I think what remains is the mapping from client side names to server side names. I already have apiName
in the attribute definition. Maybe you want to have a go at implementing the mapping. NgrxJsonApi
is aware of resourceDefinition
which can then be used in generateFilteringParams
for mapping.
from ngrx-json-api.
Only mapping remains. I'll close this since most of it has been done.
from ngrx-json-api.
Related Issues (20)
- reducer performance issues for API Success HOT 1
- Resource relationships HOT 2
- Angular 5 problems HOT 4
- API_GET_FAILED does not reset isLoading state
- document filtering and sorting HOT 1
- State does not return to `IN_SYNC` when patching resoruce HOT 5
- No url encoding - causes issues with special characters such as "[" HOT 1
- Support filter=value without path HOT 1
- Not an issue HOT 1
- Optionally add zone to pipes HOT 1
- NgrxJsonApiZoneService applies pending changes in reverse order HOT 2
- Add support of JSON:API Operations HOT 2
- Status of the project HOT 3
- Optional supports for sending changed attributes & relationships only in PATCH operation payload
- Add support for Atomic Operations Extension
- Remove package-lock.json HOT 1
- Send `meta` when creating/updating a resource
- Type mismatch in QueryParams interfaces HOT 1
- Angular 9 Support HOT 4
- Review README of the 9.0.x branch
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngrx-json-api.