From 66138bdd45020ef7197cb06958bc236f5135be53 Mon Sep 17 00:00:00 2001 From: Moroine Bentefrit Date: Wed, 18 Oct 2023 13:51:06 +0200 Subject: [PATCH] fix: validate:model memory heap (#708) --- server/src/jobs/database/validateModels.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/jobs/database/validateModels.ts b/server/src/jobs/database/validateModels.ts index ca065597bd..b350c9e1eb 100644 --- a/server/src/jobs/database/validateModels.ts +++ b/server/src/jobs/database/validateModels.ts @@ -36,12 +36,12 @@ import { Pagination } from "@/common/model/schema/_shared/mongoose-paginate" async function validateModel(model: Model | Pagination, z: ZodType) { const collectionName = model.collection.name - const cursor = await model.find({}).lean() + const cursor = model.find({}).lean() let totalCount = 0 let count = 0 const errorStats: Record = {} - for (const doc of cursor) { + for await (const doc of cursor) { try { totalCount++ z.parse(doc)