Skip to content
Official repository for the aws-record gem, an abstraction for Amazon DynamoDB.
Ruby Gherkin
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Adding standard files Mar 28, 2018
features Add Full Set of Features Jul 16, 2019
lib Bumped version to v2.4.0 Jul 16, 2019
spec Documentation Complete Jul 16, 2019
tasks Investigating last_comment Issue Jan 5, 2017
.coveralls.yml Add Basic Support for Local Secondary Indexes Jan 30, 2016
.gitignore WIP: Global Secondary Index Support Jan 11, 2017
.simplecov dirty tracking Feb 9, 2016
.travis.yml Add New Ruby Versions to Travis Feb 7, 2019
.yardopts Doc Generation Improvements Apr 22, 2016
CHANGELOG.md Bumped version to v2.4.0 Jul 16, 2019
CODE_OF_CONDUCT.md Adding standard files Mar 28, 2018
CONTRIBUTING.md Updates to CONTRIBUTING File Apr 1, 2019
Gemfile Loosen RSpec Dependency Jan 5, 2017
LICENSE.txt Modify LICENSE and NOTICE Files Jan 12, 2016
NOTICE.txt Update NOTICE Jan 12, 2016
README.md TTL support (#84) Jul 10, 2018
Rakefile Fix Task Loading May 2, 2017
VERSION
aws-record.gemspec Add Support for On-Demand Capacity to TableConfig (#89) Dec 5, 2018

README.md

Aws::Record

Build Status Code Climate Coverage Status

A data mapping abstraction over the AWS SDK for Ruby's client for Amazon DynamoDB.

This library is currently under development. More features will be added as we approach general availability, and while our initial release has as small of an API surface area as possible, the interface may change before the GA release.

We would like to invite you to be a part of the ongoing development of this gem. We welcome your contributions, and would also be happy to hear from you about how you would like to use this gem. Feature requests are welcome.

Links of Interest

Installation

Aws::Record is available as the aws-record gem from RubyGems.

gem install 'aws-record'
gem 'aws-record', '~> 1.0'

This automatically includes a dependency on the aws-sdk-resources gem, major version 2. Be sure to include the aws-sdk or aws-sdk-resources gem in your Gemfile if you need to lock to a specific version, like so:

# Gemfile

gem 'aws-record', '~> 1.0'
gem 'aws-sdk-resources', '~> 2.5'

Usage

To create a model that uses aws-record features, simply include the provided module:

class MyModel
  include Aws::Record
end

You can then specify attributes using the aws-record DSL:

class MyModel
  include Aws::Record
  integer_attr :id, hash_key: true
  string_attr  :name, range_key: true
  boolean_attr :active, database_attribute_name: "is_active_flag"
end

If a matching table does not exist in DynamoDB, you can use the TableConfig DSL to create your table:

cfg = Aws::Record::TableConfig.define do |t|
  t.model_class(MyModel)
  t.read_capacity_units(5)
  t.write_capacity_units(2)
end
cfg.migrate!

With a table in place, you can then use your model class to manipulate items in your table:

item = MyModel.find(id: 1, name: "Hello Record")
item.active = true
item.save
item.delete!

MyModel.find(id: 1, name: "Hello Record") # => nil

item = MyModel.new
item.id = 2
item.name = "Item"
item.active = false
item.save
You can’t perform that action at this time.