Ian*_*gia 15 postgresql typeorm nestjs
我正在使用 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 行,这是此行为的原因吗?我应该怎么办?
Cha*_*hai 20
以防万一您仍在寻找答案:我使用 Nestjs 和 TypeORM 遇到了同样的问题。查询中的占位符数量有限制。您可以指定{chunk: <chunkSize>}
我发现这里
所以:
await this.linioBrandRepo.remove(existingBrands, {chunk: 100});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10590 次 |
最近记录: |