Replies: 3 comments 5 replies
-
Hi, here is a repo where I tried to solve your issue : repo. I don't have exactly the same context but I think the key point here is the OneToMany relationship between Category and Product. I hope it will help you ! Debug mode for the database : adonis doc Have a nice weekend :) |
Beta Was this translation helpful? Give feedback.
-
Hello @moDevsome ! Yes it works but I'm not sure if a real jointe is done by LucidORM. When I use I can clearly see 2 SQL queries in the console when I request a product and I get the same result like before. The last method is to use the query builder and manually create the joint like this : In the response : I pushed my changes on the repo |
Beta Was this translation helpful? Give feedback.
-
I see only one query, which is weird because I don't understand how it can retrieve the category info... The last method is to use the query builder and manually create the joint Thanks for your answer Kevin, I keep this discussion opened... maybe one day someone will know how to explain why I can't reproduce the example showed in the tutorial. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everybody,
First, Happy new year at all, I wish you good jobs and happy coding.
I've a very basic "Product -> Category" database structure.
TABLE products
TABLE categories
A Product entity is associated with a Category entity through the foreign key : products.category_id
MODEL Product
MODEL Category
The relation is well taken in consideration when I get the data with a simple SQL query, but the object returned by one of the folowing methods does not contain a Category object
I've also tried differents decorators (@hasone, @belongsTo) with differents configuration in my Product model, but I could not achieve my goal.
What I want
I would like to get the data of the category associated with the product, like it's showed here in the User exmple : https://youtu.be/ftpqvs_9QN0?t=906
What I get
The query return only the product data.
Context
??? I take this opportunity to ask you an another question : here's a way to get (in debug mode) the SQL query made by the framework ?
Thankz by advance for your help.
Mickaël
Beta Was this translation helpful? Give feedback.
All reactions