My current situation involves an entity called Point:
@Entity()
export class Point {
@PrimaryGeneratedColumn('uuid')
id: string;
@IsUUID()
@PrimaryColumn({
type: 'uuid',
unique: true,
primary: true,
})
deliveryTerminalId: string;
}
Recently, I received a structure similar to the following from another API:
export interface DeliveryTerminalsInterface {
deliveryTerminalId: string;
}
I have a requirement to save an array of objects structured like DeliveryTerminalsInterface as I sync data. My own entity Point will eventually include many more @Columns().
await this.pointRepository.save(ArrayOfDeliveryTerminalsInterface);
Currently, when I run the sync method again, instead of updating existing entities with the same primary key (deliveryTerminalId), it creates new ones. This results in having duplicate entries in the database.
I'm confused about why this is happening and what I might be doing wrong. Should I consider using a different approach to handle saving/updating this data?