@moicky/dynamodb 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moicky/dynamodb",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Contains a collection of convenience functions for working with AWS DynamoDB",
package/readme.md CHANGED
@@ -15,6 +15,7 @@ Contains convenience functions for all major dynamodb operations. Requires very
15
15
  - 👻 Will **use placeholders** to avoid colliding with [reserved words](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html) if applicable
16
16
  - 🌎 Supports globally defined default arguments for each operation ([example](#configuring-global-defaults))
17
17
  - 🔨 Supports fixes for several issues with dynamodb ([example](#applying-fixes))
18
+ - 📖 Offers a convenient way to use pagination with queries
18
19
 
19
20
  ## Installation
20
21
 
@@ -219,6 +220,24 @@ const booksWithFilter = await queryAllItems(
219
220
  // additional args with filterExpression for example
220
221
  { FilterExpression: "#released BETWEEN :from AND :to" }
221
222
  );
223
+
224
+ // Pagination
225
+ const { items, hasNextPage, hasPreviousPage, currentPage } =
226
+ await queryPaginatedItems(
227
+ "#PK = :PK and begins_with(#SK, :SK)",
228
+ { PK: "User/1", SK: "Book/" },
229
+ { pageSize: 100 }
230
+ );
231
+ // items: The items on the current page.
232
+ // currentPage: { number: 1, firstKey: { ... }, lastKey: { ... } }
233
+
234
+ const { items: nextItems, currentPage: nextPage } = await queryPaginatedItems(
235
+ "#PK = :PK and begins_with(#SK, :SK)",
236
+ { PK: "User/1", SK: "Book/" },
237
+ { pageSize: 100, currentPage }
238
+ );
239
+ // items: The items on the second page.
240
+ // currentPage: { number: 2, firstKey: { ... }, lastKey: { ... } }
222
241
  ```
223
242
 
224
243
  ### Miscellaneous