I have the following config for an object:
export class Network {
@PrimaryColumn({ name: "id" })
id: string;
@Column("text")
url: string;
@ManyToOne(
type => User,
user => user.users,
{ nullable: true, onDelete: "SET NULL", onUpdate: "CASCADE" }
)
csm: User;
get_data(): {} {
return {
id: this.id,
url: this.url,
csm: this.csm ? this.csm.id : null,
};
}
}
User is another class, which doesn't refer to networks
When I save my data, it works fine:
In my table, I have a column csmId which is fulfilled with the appropriate id of a user.
The program to fulfill those values looks like
my_network.csm=csm
where csm is a User object.
Now, when I try to retrieve my data with the function get_data()
, the csm is always empty, not matter what. Other values are properly fulfilled
Can anyone help on that?
Many thanks
The answer was: adding eager (or lazy), so the join is automatically done