小编cro*_*rot的帖子

SoftDelete:无法设置标志deletedBy、deletedAt

当我删除带有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”,但数据库为空。

typeorm next.js

2
推荐指数
1
解决办法
4779
查看次数

标签 统计

next.js ×1

typeorm ×1