Class: Aws::Record::Batch
- Inherits:
-
Object
- Object
- Aws::Record::Batch
- Extended by:
- ClientConfiguration
- Defined in:
- lib/aws-record/record/batch.rb
Class Method Summary collapse
-
.read(opts = {}) {|batch| ... } ⇒ Aws::Record::BatchRead
Provides support for the Aws::DynamoDB::Client#batch_get_item for aws-record models.
-
.write(opts = {}) {|batch| ... } ⇒ Aws::Record::BatchWrite
Provides a thin wrapper to the Aws::DynamoDB::Client#batch_write_item method.
Methods included from ClientConfiguration
configure_client, dynamodb_client
Class Method Details
.read(opts = {}) {|batch| ... } ⇒ Aws::Record::BatchRead
Provides support for the Aws::DynamoDB::Client#batch_get_item for aws-record models.
Aws::Record::Batch
is Enumerable and using Enumerable methods will handle paging through all requested keys automatically. Alternatively, a lower level interface is available. You can determine if there are any unprocessed keys by calling .complete? and any unprocessed keys can be processed by calling .execute!. You can access all processed items through .items.
The batch_get_item
supports up to 100 operations in a single call and a single operation can retrieve up to 16 MB of data.
Aws::Record::BatchRead
can take more than 100 item keys. The first 100 requests will be processed and the remaining requests will be stored. When using Enumerable methods, any pending item keys will be automatically processed and the new items will be added to items
. Alternately, use .execute! to process any pending item keys.
All processed operations can be accessed by items - which is an array of modeled items from the response. The items will be unordered since DynamoDB does not return items in any particular order.
If a requested item does not exist in the database, it is not returned in the response.
If there is a returned item from the call and there’s no reference model class to be found, the item will not show up under items
.
138 139 140 141 142 143 |
# File 'lib/aws-record/record/batch.rb', line 138 def read(opts = {}) batch = BatchRead.new(client: _build_client(opts)) yield(batch) batch.execute! batch end |
.write(opts = {}) {|batch| ... } ⇒ Aws::Record::BatchWrite
Provides a thin wrapper to the Aws::DynamoDB::Client#batch_write_item method. Up to 25 PutItem
or DeleteItem
operations are supported. A single request may write up to 16 MB of data, with each item having a write limit of 400 KB.
Note: this operation does not support dirty attribute handling, nor does it enforce safe write operations (i.e. update vs new record checks).
This call may partially execute write operations. Failed operations are returned as unprocessed_items (i.e. the table fails to meet requested write capacity). Any unprocessed items may be retried by calling .execute! again. You can determine if the request needs to be retried by calling the .complete? method - which returns true
when all operations have been completed.
Please see Batch Operations and Error Handling in the DynamoDB Developer Guide for more details.
65 66 67 68 69 |
# File 'lib/aws-record/record/batch.rb', line 65 def write(opts = {}) batch = BatchWrite.new(client: _build_client(opts)) yield(batch) batch.execute! end |