Class: Aws::DynamoDB::Resource
- Inherits:
-
Object
- Object
- Aws::DynamoDB::Resource
- Defined in:
- gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb
Overview
This class provides a resource oriented interface for DynamoDB. To create a resource object:
resource = Aws::DynamoDB::Resource.new(region: 'us-west-2')
You can supply a client object with custom configuration that will be used for all resource operations.
If you do not pass :client
, a default client will be constructed.
client = Aws::DynamoDB::Client.new(region: 'us-west-2')
resource = Aws::DynamoDB::Resource.new(client: client)
Actions collapse
-
#batch_get_item(options = {}) ⇒ Types::BatchGetItemOutput
-
#batch_write_item(options = {}) ⇒ Types::BatchWriteItemOutput
-
#create_table(options = {}) ⇒ Table
Associations collapse
Instance Method Summary collapse
-
#client ⇒ Client
-
#initialize(options = {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
Instance Method Details
#batch_get_item(options = {}) ⇒ Types::BatchGetItemOutput
162 163 164 165 166 167 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 162 def batch_get_item( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.batch_get_item() end resp.data end |
#batch_write_item(options = {}) ⇒ Types::BatchWriteItemOutput
245 246 247 248 249 250 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 245 def batch_write_item( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.batch_write_item() end resp.data end |
#client ⇒ Client
32 33 34 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 32 def client @client end |
#create_table(options = {}) ⇒ Table
560 561 562 563 564 565 566 567 568 569 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 560 def create_table( = {}) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_table() end Table.new( name: resp.data.table_description.table_name, data: resp.data.table_description, client: @client ) end |
#table(name) ⇒ Table
575 576 577 578 579 580 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 575 def table(name) Table.new( name: name, client: @client ) end |
#tables(options = {}) ⇒ Table::Collection
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 587 def tables( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_tables() end resp.each_page do |page| batch = [] page.data.table_names.each do |t| batch << Table.new( name: t, client: @client ) end y.yield(batch) end end Table::Collection.new(batches) end |