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

177
Vistas
Getting data from foreign key of other table - TypeOrm(Mysql)

I am using nestjs and typeorm (Mysql). I have these tables users, orders and invoices. Now invoices table has a foreign key linking to orders table and orders table links to user table.

Now when i am fetching invoices , i want to query user table , but i dont have foreign key for user table instead i have for order table and order table has foreign key for user table.

Is there any way to query user table when fetching invoice data ?

I tried the below code

const query = this.createQueryBuilder('invoice');

    query.innerJoinAndSelect('invoice.order', 'order');
    query.innerJoinAndSelect('order.user', 'user');

But it is giving this error

[Nest] 96607   - 11/09/2021, 11:08:49   [ExceptionsHandler] Relation with property path user in entity was not found. 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's more an advice than a solution.

TypeORM is not very intuitive and the documentation is not clear about it.

I reccomend you to change to a futuristic ORM, "PRISMA", the migration is very easy.

After installing it run this commands:

This command generates the schema automatically bassed on your database.

prisma introspect

This command applies the changes in your prisma schema.

prisma generate

After that youll have a pretty easy and accurate access to relationships.

about 4 years ago · Juan Pablo Isaza Denunciar
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