Skip to content

Relation data not available #360

@rajkumarpb

Description

@rajkumarpb

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions