active-dynamo

An ActiveRecord like ODM for AWS DynamoDB

Installation

gem install active-dynamo

Usage

Currently, the supported operations are as follows:

  • Define a model in a way similar to ActiveRecord, calling table_name and attributes functions:
class  < ActiveDynamo::Base
  table name: 'account', partition_key: :no, sort_key: :balance
  attributes no: Integer, balance: Integer, kind: String
end
  • Create a new record:
 = .new(no: 123, balance: 2000, kind: 'current')
.save

# or use `create`
 = .create(no: 123, balance: 2000, kind: 'current')
  • Query the table using methods such as:
.all

.where(no: 123, balance: 2000)
.where("no = 123 and balance >= 2000 and kind = 'current'")

.find(no: 123, balance: 2000)
  • Update a record
 = .first
.update(kind: 'savings')
  • Delete a record
.destroy(no: 123, balance: 2000)

License

See LICENSE.