Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

57
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!