Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

523
Views
Typeorm, MongoDB and TypeGraphQL - Populate - Lookup

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?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!