I am facing an issue when trying to update multiply records in once. I am using method save of Repository of entity.
This is how it is used as written in the docs : save - Saves a given entity or array of entities. If the entity already exists in the database, then it's updated. If the entity does not exist in the database yet, it's inserted. It saves all given entities in a single transaction (in the case of entity manager is not transactional). Also supports partial updating since all undefined properties are skipped. In order to make a value NULL, you must manually set the property to equal null.
await manager.save(user);
await manager.save([
category1,
category2,
category3
]);
This is how I am using it :
@Injectable()
export class PersonService{
constructor(
@InjectRepository(PersonEntity)
private personService: Repository<PersonEntity>,
) {}
async saveAll(persons: PersonEntity[]) {
return await this.personService.save(persons);
}
}
The persons input param contains only keys attr and wanted attr to update.
And I am getting this error: [ExceptionsHandler] null value in column "*****" violates not-null constraint +17149ms QueryFailedError: null value in column "****" violates not-null constraint
Thank you for you help!