我正在使用 PostgresSQL 并且我正在尝试删除列中的所有数据(我的实体由 Id an 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);
}
}
但是,控制台向我抛出此错误:'错误:绑定(bind)消息有 9914 个参数格式,但有 0 个参数'
此实体中的总行数为 115900 行,这是此行为的原因吗?我该怎么办 ?
谢谢
最佳答案
以防万一您仍在寻找答案:
我使用 Nestjs 和 TypeORM 遇到了同样的问题。查询中的占位符数量有限制。您可以指定 {chunk: <chunkSize>}
我发现 here
所以例如:
await this.linioBrandRepo.remove(existingBrands, {chunk: 100});
关于postgresql - 错误 : bind message has 9914 parameter formats but 0 parameters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66906294/