Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

aonemd/active-dynamo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

active-dynamo

An ActiveRecord like ODM for AWS DynamoDB

Gem Version

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 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.

Releases

No releases published

Packages

No packages published

Languages