Skip to content

Commit 5366430

Browse files
committed
Add document about pagination
1 parent 52b6fd8 commit 5366430

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This package provides QueryBuilder for DynamoDB.
2323
- [Filter Expressions for Query](#filter-expressions-for-query)
2424
- [Working with Scans in DynamoDB](#working-with-scans-in-dynamodb)
2525
- [Filter Expressions for Scan](#filter-expressions-for-scan)
26+
- [Paginating the Results](#paginating-the-results)
2627
- [Using Global Secondary Indexes in DynamoDB](#using-global-secondary-indexes-in-dynamodb)
2728
- [Querying a Global Secondary Index](#querying-a-global-secondary-index)
2829
- [Models](#models)
@@ -40,8 +41,9 @@ This package provides QueryBuilder for DynamoDB.
4041
I started trying to make simple QueryBuilder because:
4142

4243
- I want to use DynamoDB with Laravel. (e.g., authenticate with custom user provider)
43-
- I don't want to extend Eloquent Query Builder because DynamoDB looks quite different from relational databases.
4444
- I want to use a simple API which doesn't need to worry about cumbersome things like manually handling Expression Attributes.
45+
- I don't want to make it fully compatible with Eloquent because DynamoDB looks quite different from relational databases.
46+
- However, I want to extend Laravel's code as much as I can to keep additional implementation simple.
4547
- I'm longing for [jessengers/laravel-mongodb](https://github.com/jenssegers/laravel-mongodb). What if we have that for DynamoDB?
4648

4749
## Installation
@@ -274,6 +276,27 @@ $response = DB::table('Thread')
274276
->scan();
275277
```
276278

279+
#### Paginating the Results
280+
281+
If there are more results, the result contains `LastEvaluatedKey`.
282+
283+
```php
284+
$response = DB::table('ProductCatalog')
285+
->limit(5)
286+
->scan();
287+
288+
$response['LastEvaluatedKey']; // array
289+
```
290+
291+
Pass `LastEvaluatedKey` to the `exclusiveStartKey` clause to retrieve the next results.
292+
293+
```php
294+
$response = DB::table('ProductCatalog')
295+
->exclusiveStartKey($response['LastEvaluatedKey'])
296+
->limit(5)
297+
->scan();
298+
```
299+
277300
### Using Global Secondary Indexes in DynamoDB
278301

279302
[corresponding document](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html)

0 commit comments

Comments
 (0)