使用 SoftRemove 和 Unique 装饰器的 TypeORM

问题描述

请帮我解决一个问题。我使用 nestJS + TypeORM softRemove/softDelete 来删除记录。而且我只想将 @Unique 装饰器应用于未删除的记录。 我的删除方法如:

public async delete(id: number): Promise<UpdateResult> {
   return await this.repo.softDelete(id);
}

在实体中将是完美的:

@Entity('role')
@Unique('UQ_TITLE',['title','deletedDate IS NULL'])//IS NULL not supported there :(
export class Role {

    @Column({ type: 'varchar',nullable: false })//may be exists some expression for column settings
    title: string;

    @DeleteDateColumn({ select: false })
    deletedDate?: Date;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)