Giter Site home page Giter Site logo

Comments (4)

abdulhaq-e avatar abdulhaq-e commented on August 26, 2024

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.

remmeier avatar remmeier commented on August 26, 2024

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.

abdulhaq-e avatar abdulhaq-e commented on August 26, 2024

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.

abdulhaq-e avatar abdulhaq-e commented on August 26, 2024

Only mapping remains. I'll close this since most of it has been done.

from ngrx-json-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.