Is it possible in TypeORM, PostgreSQL, AdminJs with One to Many table relationships to immediately receive data from the associated table, and not a link to this data, as in my example.
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({ unique: true })
userColum: string;
@OneToMany(() => Car, (car) => car.car)
cars: Car[];
}
Car:----------------------------
@Entity()
export class Car extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@ManyToOne(() => User, (user: User) => user.userColum, { eager: true })
car: Car;
@Column()
name: string;
}
ТI get a link here:
@ManyToOne(() => User, (user: User) => user.userColum, { eager: true })
But I would like to pull up the data itself. This seems to require an additional request. Or will you have to somehow custom make the request yourself? If yes, how can this be done?
Next I use AdminJS to display data and act on tables
I'm using AdminJS for the front-end (This requirement is not made by me. Therefore, I do not have routes, this is done by AdminJS under the hood. I did not find any mention of my situation in the AdminJS documentation. At the moment it turns out that instead of the desired data is the value from the userColum column, when I display the Cars table in a column called CarId, I get a reference to userColum. The link is displayed as an index of the Users table - 1, 2, 3 and is clickable. Here, instead of displaying 1, 2, 3, I want to see the text value “userColum 1”, “userColum 2”, “userColum 3”, which are in the Users column userColum. Accordingly, when I click on the link, I get the necessary data of the userColum column. And I want the data to be immediately displayed inside the Cars table.
If we remove { eager: true } Then in the database in the Cars table in the CarId column there will be id from the Users table, but nothing is displayed on the front-end AdminJs.