question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Relation data not available

See original GitHub issue

Models:


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:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rajkumarpbcommented, Dec 23, 2019

That’s it! That’s the issue. Too embarrassing to have such silly mistake. Thanks @zMotivat0r

0reactions
michaelyalicommented, Dec 23, 2019

@ManyToOne(type => Users, users => users.id) user:Users | null;

join: { users: { eager: true, allow:[‘name’] } }

your relation in the entity is user but in the controller, you specify users As I said earlier, please read the docs

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found