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
158 159 160 161 162 163 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 158 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
240 241 242 243 244 245 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 240 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
563 564 565 566 567 568 569 570 571 572 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 563 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
578 579 580 581 582 583 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 578 def table(name) Table.new( name: name, client: @client ) end |
#tables(options = {}) ⇒ Table::Collection
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 590 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 |