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

599
Visualizações
NestJS/typeORM Vanilla - Cannot query across many-to-many for property

I'm using NestJS in the vanillaJS way (because I can't write typescript) and I have a many-to-many relation from user to bubble.

I want to write a updateUser-Route in which I also want to be able to update the bubble-affiliation.

But when I do so like this: user.controller.js:

  @Patch(':id')
  @Bind(Param('id'), Body())
  async updateUser(id, body) {
    if (Object.keys(body).length !== 0) {
      return await this.userService.updateUser(id, body);
    }
    throw new BadRequestException('Missing Body');
  }

user.service.js:

  async updateUser(id, user) {
    return await this.userRepository.update(id, user);
  }

I get this error: Cannot query across many-to-many for property bubble

This is my user.entity.js:

var EntitySchema = require('typeorm').EntitySchema;
var User = require('./user.model').User;
var Bubble = require('../bubble/bubble.model').Bubble;

module.exports = new EntitySchema({
  name: 'User',
  target: User,
  columns: {
    id: {
      primary: true,
      type: 'int',
    },
    handle: {
      type: 'varchar',
    },
    lastCheck: {
      type: 'datetime',
      default: () => 'NOW()',
    },
    rating: {
      type: 'int',
    },
  },
  relations: {
    bubble: {
      type: 'many-to-many',
      target: 'Bubble',
      joinTable: true,
      cascade: true,
    },
  },
});

in postman I try to call it like this:

{
    "rating": 10,
    "bubble": [{
        "id": "1234"
    }]
}

if I leave bubble out it works and rating gets updated. with bubble I get the error described above

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