Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

521
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda