How to do referencesmany in loopback 4 to populate relational model data? #7153
Replies: 7 comments 1 reply
-
Can you provide and example, I had spend almost three weeks in your documentation and couldn't able to figure it out, you could have include this kind of one sample in you shopping cart examples. Is it possible to use hasMany without using belongsTo in the target model |
Beta Was this translation helpful? Give feedback.
-
it is very clear on loopback 4, |
Beta Was this translation helpful? Give feedback.
-
In your example source model’s id as the foreign key property (customerId) in the target model. But in my case I don't have any relation with category white creating the product. When I create a category I will be adding products Ids as array in to it. When I access category I need to populate product detail as well. Is there any way to do it without foreign key property in the target model? |
Beta Was this translation helpful? Give feedback.
-
{ This is my application version. I have found solution for my issue in lb3 |
Beta Was this translation helpful? Give feedback.
-
Any updates on this ? we are also digging into documents and NO CLUE how to implement "referencesMany" in repositories. Please help if anything around this solve issue |
Beta Was this translation helpful? Give feedback.
-
Im still using lb3 cause the feature is not implemented yet. 3 years passed... |
Beta Was this translation helpful? Give feedback.
-
Can you explain how to do referencesmany in loopback 4
https://loopback.io/doc/en/lb3/Embedded-models-and-relations.html#referencesmany
I wanted to store categories and its products Ids as an array in the collection. On get method I need show category info as well as product details as mentioned below .Is there any best with relational model in loopback? I am new in Loopback and node js, please suggest best practice.
Category
Products
Result
Beta Was this translation helpful? Give feedback.
All reactions