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

feat(repository): add more helpers for HasManyThrough #5605

Merged
merged 1 commit into from
Jun 3, 2020
Merged

Conversation

agnes512
Copy link
Contributor

@agnes512 agnes512 commented May 29, 2020

Add two more helpers for HasManyThrough relation

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@agnes512 agnes512 requested a review from hacksparrow as a code owner May 29, 2020 14:03
@agnes512 agnes512 requested review from bajtos and jannyHou May 29, 2020 14:05
@agnes512 agnes512 force-pushed the hmt-helpers branch 3 times, most recently from 0b3a74b to 9fb04db Compare May 29, 2020 18:17
@agnes512
Copy link
Contributor Author

Added two helpers. They are all for deleting through models as we decided to have the delete method this way https://github.com/strongloop/loopback-next/pull/4438/files#r402105078

@agnes512 agnes512 added the Relations Model relations (has many, etc.) label May 29, 2020
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as far as I am concerned.

I am not familiar enough with the code in packages/repository/src/repositories/constraint-utils.ts to be able to review the changes properly. Please get the approval from FA owners before landing.

@dhmlau dhmlau added this to the Jun 2020 milestone Jun 1, 2020
* keyTo: 'productId',
* },
* };
* createThroughConstraint(resolvedMetadata, {id: 3, name: 'a product'});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additional query field reminds me sth(sorry don't remember where is the original chat :p) :

We want to distinguish the query on through model(CategoryProductLink) and target model(Product), how do we achieve that?

For example, {name: 'a product'} seems for target model, and createThroughConstraint applies for through model, and that's why name is ignored here. But:

  • where is the place that processes the target model's filter?
  • how to specify the through model's filter?

(I started from the helper function, might missing the code/docs if they are created other places.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jannyHou I think these helpers are just for handling the relation metadata. And filters are handled in the hasManyThrough repository. Here is an example in the original design: find method. They won't be included in this PR. But I'd love to discuss it:

So far from those two community PRs(#2359 , #4438 ), I only see the target model is capable of applying filters. Not sure if we need it for through models ( I don't see the reason to allow filtering through models tho). Do we need it?

Copy link
Contributor

@jannyHou jannyHou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice progress!

@agnes512 agnes512 merged commit c795544 into master Jun 3, 2020
@agnes512 agnes512 deleted the hmt-helpers branch June 3, 2020 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Relations Model relations (has many, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants