I am working with Typeorm and MongoDB. I have a UserAlert entity that saves the _id of another User entity as a field. My question is how you can get the information of the entity that that _id refers to. It would be something similar to populate in mongoose.
Example:
User:
@Entity({ name: 'Users' })
export default class User extends BaseEntity {
@ObjectIdColumn()
_id!: ObjectID;
@Column('string')
firstName!: string;
@Column('string')
lastName!: string;
@Column('string')
phoneNumber!: string;
}
User Alert:
@Entity({ name: 'UserAlerts' })
export default class UserAlert extends BaseEntity {
@ObjectIdColumn()
_id!: ObjectID;
//REFERENCE
@ObjectIdColumn()
userId!: ObjectID;
@Column('date')
date!: Date;
}
Result: User Alert
{
"_id":"asdbfsdf32112312dasdas",
"date":"15/09/2021",
"User":{
"_id":"asdas6d5412634123654",
"firstName":"Jorge",
"lastName":"Mamani",
"phoneNumber":"465465"
}
}
How would I have to present the data in Type GraphQL?