From 5f206c061b34ce57ffbcb503964a3e05c8e9c83a Mon Sep 17 00:00:00 2001 From: James Crosby Date: Wed, 1 May 2024 17:28:31 +0100 Subject: [PATCH] set the dynamodb query command Limit option to options.limit by default --- lib/model.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/model.js b/lib/model.js index 4603313..6e4d573 100644 --- a/lib/model.js +++ b/lib/model.js @@ -920,9 +920,11 @@ class BaseModel { ExpressionAttributeValues: mergedExprAttributeValues, ExpressionAttributeNames: mergedExprAttributeNames, ...(ExclusiveStartKey && {ExclusiveStartKey}), - // TODO: not sure if this will mess up pagination? - // set the dynamodb Limit to the options limit, or the maximum supported, so that we don't evaluate more items than necessary - // ...(options.limit && {Limit:options.limit}) + // set the dynamodb Limit to the options limit, so that we don't + // evaluate more items than necessary. If making a query with a + // filter expression it may make sense to specify a larger limit, + // in which case that can be specified in otherOptions.Limit + ...(options.limit && {Limit: options.limit}) }, otherOptions); } }