我正在使用 PostgresSQL,并且尝试删除列中的所有数据(我的实体由 和 组成id)name,但是当我运行代码时,会出现一条错误消息。
这是代码(我使用 NestJs 和 TypeOrm):
@Injectable()
export class ClearLinioBrands {
constructor(
@InjectRepository(LinioBrand)
private linioBrandRepo: Repository<LinioBrand>,
) {}
async execute(): Promise<void> {
const existingBrands = await this.linioBrandRepo.find();
await this.linioBrandRepo.remove(existingBrands);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我在控制台上收到以下错误:
@Injectable()
export class ClearLinioBrands {
constructor(
@InjectRepository(LinioBrand)
private linioBrandRepo: Repository<LinioBrand>,
) {}
async execute(): Promise<void> {
const existingBrands = await this.linioBrandRepo.find();
await this.linioBrandRepo.remove(existingBrands);
}
}
Run Code Online (Sandbox Code Playgroud)
该表中有 115900 行,这是此行为的原因吗?我应该怎么办?