From af188689000ed3e00107bf6238a0b4543775d346 Mon Sep 17 00:00:00 2001 From: Birm Date: Wed, 24 Apr 2024 10:13:08 -0400 Subject: [PATCH] limit find query by default --- service/database/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/service/database/index.js b/service/database/index.js index cca743c..377492a 100644 --- a/service/database/index.js +++ b/service/database/index.js @@ -24,7 +24,9 @@ class Mongo { query = transformIdToObjectId(query); const collection = getConnection(database).collection(collectionName); - const data = await collection.find(query).toArray(); + let { _page = 0, _pageSize = 1000, ...filterQuery } = query; + const _skip = _page * _pageSize; + const data = await collection.find(filterQuery).skip(_skip).limit(_pageSize).toArray(); /** allow caller method to toggle response transformation */ if (transform) {