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

58
Vistas
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 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