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

59
Visualizações
TypeORM replacing database rows when it should be adding new rows

I have the following entity:

@Entity(‘team_player’)
export class TeamPlayer {

  @PrimaryColumn({ type: ‘uuid’, primary: false })
  @ApiProperty({ type: ‘string’, format: ‘uuid’ })
  player_id: string;

  @ApiProperty({ type: ‘string’, format: ‘uuid’ })
  @Column({ type: ‘text’ })
  team_id: string;
}

And am running the following test:

  beforeEach(async () => {
    // Set up 3 players for one team
    await TeamPlayer.save({
      player_id: player1Id,
      team_id: teamId,
    });
    await TeamPlayer.save({
      player_id: player2Id,
      team_id: teamId,
    });
    await TeamPlayer.save({
      player_id: player3Id,                           // only row that gets saved in final result
      team_id: teamId,
    });
  });

When I look at my DB, only the last player gets saved, assuming it’s replacing the previous ones that got saved. I don’t want that behaviour but rather to have all 3 rows.

team_id           player_id
---------------------------
5555555           player3Id

Is that something that can be fixed by simply changing the entity?

about 4 years ago · Santiago Gelvez
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