当我删除带有softDelete列的实体deletedAt并且deletedBy为空或未设置时。
如果我尝试softRemove,它只会设置deletedAt标志。
以下是实体的一些代码:
@DeleteDateColumn({ name: 'deleted_at'})
deletedAt: Date;
@Column({ type: 'varchar', name: 'deleted_by', nullable: true })
deletedBy: string;
Run Code Online (Sandbox Code Playgroud)
对于服务:
public async delete(id: string): Promise<void> {
const talent: Talent = await this.talentRepository.findOne(id);
if (!talent) throw new NotFoundException(`Talent with ID ${id} Not Found`);
talent.deletedBy = "John Doe";
await this.talentRepository.softDelete(talent);
}
Run Code Online (Sandbox Code Playgroud)
如果我登录此服务,参数deletedBy将设置为“John Doe”,但数据库为空。