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

Add support for "include" and "fields" to findById (REST API) #1721

Closed
6 tasks
bajtos opened this issue Sep 18, 2018 · 4 comments · Fixed by #4745
Closed
6 tasks

Add support for "include" and "fields" to findById (REST API) #1721

bajtos opened this issue Sep 18, 2018 · 4 comments · Fixed by #4745
Labels
developer-experience Issues affecting ease of use and overall experience of LB users feature parity feature good first issue Juggler REST Issues related to @loopback/rest package and REST transport in general

Comments

@bajtos
Copy link
Member

bajtos commented Sep 18, 2018

Let's say our application has a Customer model that has many Order instances.

In LoopBack 3.x, one can can fetch a customer with all their orders.

GET /api/customers/123?filter[include]=orders

We should support this feature in LoopBack 4 too.

Acceptance criteria

  • Find which Filter properties are supported by findById
  • Create a new TypeScript interface describing these properties. This new interface should be most likely provided by loopback-datasource-juggler.
  • Modify EntityCrudRepository.prototype.findById - fix the type of the filter argument to use the new TypeScript type describing only the properties supported by findById. Fix all implementations of this interface, include tests.
  • Create a function for obtaining JSON Schema and OpenAPI schema for this new interface. Build on top of REST API to find models using a filter  #1679
  • Update Sequence that we support these two fields for findById.
  • Throw errors ( or warning) when use order, skip, limit, and where clauses with findById. See Filter on findById is ignoring the where clause #3336.

Done in #4114

  • Update the REST Controller template and all example controllers to support this new filter parameter.
  • Update any documentation pages and snapshot tests showing findById implementation to include the new filter argument.

Note: the argument name filter may not be descriptive enough, feel free to find a better name.

IMPORTANT: This feature depends on #1352.

@bajtos bajtos added the REST Issues related to @loopback/rest package and REST transport in general label Sep 18, 2018
@mrbatista
Copy link
Contributor

@bajtos is duplicate of #1352?
In loopback 3.x is it possible to use include for find(), findById(), findOne().
Does loopback 4 support only findById()?

@bajtos
Copy link
Member Author

bajtos commented Oct 26, 2018

In loopback 3.x is it possible to use include for find(), findById(), findOne().
Does loopback 4 support only findById()?

LoopBack 4 does not support inclusion of related models yet. The issue #1352 is keeping track of implementing support for filter[include] at Repository level for find/findOne/findById and it's a pre-requisite for this issue.

@bajtos bajtos changed the title Add support for "include" and "fields" to findById Add support for "include" and "fields" to findById (REST API) Nov 6, 2018
@stale
Copy link

stale bot commented Nov 10, 2019

This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.

@tayyabjamil
Copy link

any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
developer-experience Issues affecting ease of use and overall experience of LB users feature parity feature good first issue Juggler REST Issues related to @loopback/rest package and REST transport in general
Projects
None yet
4 participants