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

Fix the filter for hasManyThrough relation #197

Closed
jannyHou opened this issue Sep 21, 2018 · 2 comments
Closed

Fix the filter for hasManyThrough relation #197

jannyHou opened this issue Sep 21, 2018 · 2 comments
Labels

Comments

@jannyHou
Copy link
Contributor

Description/Steps to reproduce

A follow up issue for strongloop/loopback#4006

Cloudant connector has the problem, haven't checked other connectors:

When many-to-many relation has a through model, for example

  • Team hasMany Resource through TeamResource
  • Resource hasMany Team through TeamResource

Query a team with its resources included using Team.findById(teamId, {include: {relation: 'resources', scope: {limit: 100}}})

The connector first finds all the through model instances using teamId, then do a recursive find for each of the teamResources using its resourceId, and the limit filter is applied on it, which causes the problem.

As a workaround fix, PR #196 allows user to define a globalLimit to retrieve all the related model instances.

The real fix should:

  • compare with the other connectors see how they deal with include filter
  • investigate the possibility to find related model from through model in one query not a bunch of recursive queries, at least in the cloudant connector
  • if it's feasible to apply limit/skip/offset on the related model, create a PR for such a fix. If it's restricted by design, then document it and this workaround.
@stale
Copy link

stale bot commented Jul 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 11, 2019
@stale
Copy link

stale bot commented Jul 25, 2019

This issue has been closed due to continued inactivity. Thank you for your understanding. 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.

@stale stale bot closed this as completed Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant