Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda