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.feature('resource') 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.feature('resource') 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
524 525 526 527 528 529 530 531 532 533 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 524 def create_table( = {}) resp = Aws::Plugins::UserAgent.feature('resource') 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
539 540 541 542 543 544 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 539 def table(name) Table.new( name: name, client: @client ) end |
#tables(options = {}) ⇒ Table::Collection
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
# File 'gems/aws-sdk-dynamodb/lib/aws-sdk-dynamodb/resource.rb', line 551 def tables( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.feature('resource') 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 |