-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
hasOne() and belongsTo() not working in loopback4 #2209
Comments
@raymondfeng Can you please help me in this if you have brief idea ? |
Hi @drplutus, please create a small app reproducing the issue per our bug reporting instructions. @b-admike I think you are most familiar with relations, could you PTAL? |
I have create one simple api which is going to fetch the data from database(Mysql).
Table 1 is belongs to table one. Suppose we fetch data from person table then respective info table data will fetch. person.model.ts:
info.model.ts:
person.repository.ts
Api code which is called from controller
It will return error : 500 TypeError: Cannot read property 'target' of undefined Just i want to get person information with address. |
First of all,
Generating the correct schema for different CRUD endpoints is a bit tricky:
I think we need two schemas, possibly even two TypeScript models/interfaces. Please refer to discussion in #2124 for more details.
Sorry, I don't have bandwidth to re-create a working LB4 application from your instructions and thus I cannot look into details of the error you are encountering. Can you please follow the instructions in https://loopback.io/doc/en/contrib/Reporting-issues.html#loopback-4x-bugs and provide us with a LB4 app that we can simply |
try, instead of may be it will work |
I spot some problems that might crash the app:
in Info.model:
Ref: HasOne relation customizing name Also, we support inclusion for relations now :D check out Querying related models on our site! |
Feel free to re-open the issue if it's not solved yet. Thanks! |
I have try with following code but i will got only first table record, there are missed second table info.
person.model.ts:
info.model.ts:
person.repository.ts
Current Behavior
But when i will call the api using explorer they have return following schema
Is there any solution for this?
The text was updated successfully, but these errors were encountered: