Relation data not available
See original GitHub issueModels:
import {Column,Entity, OneToMany,PrimaryGeneratedColumn} from "typeorm";
import { WLogin } from "./wlogin.entity";
@Entity("users" ,{schema:"public" } )
export class Users {
@PrimaryGeneratedColumn({
type:"bigint",
name:"id"
})
id:string;
@Column("name")
name:string | null;
@OneToMany(()=>WebLogin, (wlogin: WLogin)=>wlogin.user,{ onDelete: 'CASCADE' ,onUpdate: 'CASCADE' })
wLogins:WLogin[];
}
WLogin
import { Column,Entity,Index,JoinColumn,ManyToOne,PrimaryGeneratedColumn, JoinTable } from "typeorm";
import { Users } from "./users.entity";
@Entity("wlogin" ,{schema:"public" })
export class WebLogin {
@PrimaryGeneratedColumn({
type:"bigint",
name:"id"
})
id:string;
@JoinColumn({ name:'user_id'})
@ManyToOne(type => Users, users => users.id)
user:Users | null;
}
But when I hit the service http://localhost:3000/weblogin?join=users, I’m only getting fields from wlogin table. But it should display the users name as well as mentioned in the entity. Can someone tell me what am I doing wrong in this case?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Troubleshoot table relationships - Microsoft Support
Sometimes Excel fails to detect relationship between tables. ... There can be various reasons for this: ... The data types might not be...
Read more >Laravel eloquent one to many relationship data not showing
i tried your solution, but i got this error, "Undefined variable: $student.. can you please suggest correct revision. for controller and blade.
Read more >Power BI Relationships Not Working? Four Steps to Debug for ...
Are your Power BI Relationships not working ? It can be so frustrating when that happens. The good news is that the four...
Read more >Power BI Relationships Not Working? How to Fix ... - YouTube
Are your Power BI Relationships not working ? It can be so frustrating when that happens. In this video we discuss how you...
Read more >Relate Your Data - Tableau Help
Relationships are a dynamic, flexible way to combine data from multiple tables for ... This video is either unavailable or not supported in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s it! That’s the issue. Too embarrassing to have such silly mistake. Thanks @zMotivat0r
your relation in the entity is
user
but in the controller, you specifyusers
As I said earlier, please read the docs