You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+85-6
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,11 @@ You can find an example implementation in [kitar/simplechat](https://github.com/
53
53
*[Using Global Secondary Indexes](#using-global-secondary-indexes)
54
54
+[index()](#index)
55
55
*[Atomic Counter](#atomic-counter)
56
+
*[Batch Operations](#batch-operations)
57
+
+[batchGetItem()](#batchgetitem)
58
+
+[batchPutItem()](#batchputitem)
59
+
+[batchDeleteItem()](#batchdeleteitem)
60
+
+[batchWriteItem()](#batchwriteitem)
56
61
*[DynamoDB-specific operators for condition() and filter()](#dynamodb-specific-operators-for-condition-and-filter)
57
62
+[Comparators](#comparators)
58
63
+[functions](#functions)
@@ -197,7 +202,6 @@ class User extends Model implements AuthenticatableContract
197
202
}
198
203
```
199
204
200
-
> **Note**
201
205
> Note that this model is implementing `Illuminate\Contracts\Auth\Authenticatable` and using `Illuminate\Auth\Authenticatable`. This is **optional**, but if we use them, we can use this model with authentication as well. For authentication, please refer to [Authentication section](#authentication-with-model)) for more details.
202
206
203
207
### Basic Usage
@@ -234,7 +238,6 @@ public static function scan($exclusiveStartKey = null, $sort = 'asc', $limit = 5
234
238
}
235
239
```
236
240
237
-
> **Note**
238
241
> DynamoDB can only handle result set up to 1MB per call, so we have to paginate if there are more results. see [Paginating the Results](#paginating-the-results) for more details.
> Instead of marshaling manually, pass a plain array. `Kitar\Dynamodb\Query\Grammar` will automatically marshal them before querying.
479
481
480
482
#### putItem()
@@ -547,7 +549,6 @@ DB::table('ProductCatalog')
547
549
]);
548
550
```
549
551
550
-
> **Note**
551
552
> Note that we specify `attribute_not_exists` for the operator of condition. This is DynamoDB-specific operator which called `function`. See [DynamoDB-specific operators for condition() and filter()](#dynamodb-specific-operators-for-condition-and-filter) for more details.
> Note that DynamoDB's `ScanIndexForward` is a feature for `query`. It will not work with `scan`.
630
630
631
631
### Working with Scans
@@ -755,6 +755,86 @@ DB::('Thread')->key([
755
755
]);
756
756
```
757
757
758
+
### Batch Operations
759
+
760
+
Batch operations can get, put or delete multiple items with a single call. There are some DynamoDB limitations (such as items count, payload size, etc), so please check the documentation in advance. ([BatchGetItem](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html), [BatchWriteItem](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html))
761
+
762
+
#### batchGetItem()
763
+
764
+
```php
765
+
DB::table('Thread')
766
+
->batchGetItem([
767
+
[
768
+
'ForumName' => 'Amazon DynamoDB',
769
+
'Subject' => 'DynamoDB Thread 1'
770
+
],
771
+
[
772
+
'ForumName' => 'Amazon DynamoDB',
773
+
'Subject' => 'DynamoDB Thread 2'
774
+
]
775
+
]);
776
+
```
777
+
778
+
#### batchPutItem()
779
+
780
+
```php
781
+
DB::table('Thread')
782
+
->batchPutItem([
783
+
[
784
+
'ForumName' => 'Amazon DynamoDB',
785
+
'Subject' => 'DynamoDB Thread 3'
786
+
],
787
+
[
788
+
'ForumName' => 'Amazon DynamoDB',
789
+
'Subject' => 'DynamoDB Thread 4'
790
+
]
791
+
]);
792
+
```
793
+
794
+
> This is a handy method to batch-put items using `batchWriteItem`
795
+
796
+
#### batchDeleteItem()
797
+
798
+
```php
799
+
DB::table('Thread')
800
+
->batchDeleteItem([
801
+
[
802
+
'ForumName' => 'Amazon DynamoDB',
803
+
'Subject' => 'DynamoDB Thread 1'
804
+
],
805
+
[
806
+
'ForumName' => 'Amazon DynamoDB',
807
+
'Subject' => 'DynamoDB Thread 2'
808
+
]
809
+
]);
810
+
```
811
+
812
+
> This is a handy method to batch-delete items using `batchWriteItem`
813
+
814
+
#### batchWriteItem()
815
+
816
+
```php
817
+
DB::table('Thread')
818
+
->batchWriteItem([
819
+
[
820
+
'PutRequest' => [
821
+
'Item' => [
822
+
'ForumName' => 'Amazon DynamoDB',
823
+
'Subject' => 'DynamoDB Thread 3'
824
+
]
825
+
]
826
+
],
827
+
[
828
+
'DeleteRequest' => [
829
+
'Key' => [
830
+
'ForumName' => 'Amazon DynamoDB',
831
+
'Subject' => 'DynamoDB Thread 1'
832
+
]
833
+
]
834
+
]
835
+
]);
836
+
```
837
+
758
838
### DynamoDB-specific operators for condition() and filter()
759
839
760
840
For `condition` and `filter` clauses, we can use DynamoDB's comparators and functions.
0 commit comments