Skip to content

Loopback vs JSONAPI filter syntax #70

Open
@digitalsadhu

Description

@digitalsadhu

Description

Loopback provides the necessary syntax for filtering results.

JSON API is agnostic about how filtering is implemented and only specifies that the filter key is used. In some ways, since loopback does use the filter key, the implementation is already correct though perhaps not ideal.

Loopback example:

https://docs.strongloop.com/display/public/LB/Where+filter

filter[where][property]=value
filter[where][property][op]=value

Note the use of the where namespace which, while not violating anything in JSON API, could be removed for a better API.

JSON API example

http://jsonapi.org/format/#fetching-filtering

The filter query parameter is reserved for filtering data. Servers and clients SHOULD use this key for filtering operations.
Note: JSON API is agnostic about the strategies supported by a server. The filter query parameter can be used as the basis for any number of filtering strategies.

The following is how I would expect an ideal solution to work:

filter[property]=value
filter[property][op]=value

Also important to note is that it may cause us issues to use the filter key in a non standard way since all the url based operations in loopback use this key. Eg. Offset, limit, where, fields. It may simply be easier to treat this as technically compliant and leave it at that in the short term.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions