Skip to content

Commit

Permalink
limit find query by default
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Apr 24, 2024
1 parent 3466a65 commit af18868
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion service/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit af18868

Please sign in to comment.