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
andattributes
functions:
class Account < ActiveDynamo::Base
table name: 'account', partition_key: :no, sort_key: :balance
attributes no: Integer, balance: Integer, kind: String
end
- Create a new record:
account = Account.new(no: 123, balance: 2000, kind: 'current')
account.save
# or use `create`
account = Account.create(no: 123, balance: 2000, kind: 'current')
- Query the table using methods such as:
Account.all
Account.where(no: 123, balance: 2000)
Account.where("no = 123 and balance >= 2000 and kind = 'current'")
Account.find(no: 123, balance: 2000)
- Update a record
account = Account.first
account.update(kind: 'savings')
- Delete a record
Account.destroy(no: 123, balance: 2000)
License
See LICENSE.