Lotus::Model DynamoDB Adapter
An adapter is a concrete implementation of persistence logic for a specific database.
-- jodosha, Lotus::Model
This adapter implements persistence layer for a Amazon DynamoDB, and it pretends to be a really sane solution to fully experience DynamoDB advantages with Ruby.
It is built using AWS::DynamoDB::Client
, which is a part of aws-sdk
gem and implements latest version of DynamoDB protocol.
Status
Links
- API Doc: http://rdoc.info/gems/lotus-dynamodb
- Bugs/Issues: https://github.com/krasnoukhov/lotus-dynamodb/issues
Installation
Add this line to your application's Gemfile:
gem 'lotus-dynamodb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install lotus-dynamodb
Usage
Please refer to Lotus::Model docs for any details related to Entity, Repository, Data Mapper and Adapter.
Data types
This adapter supports coercion to all DynamoDB types, including blobs and sets.
List of Ruby types that are supported:
- AWS::DynamoDB::Binary –
B
- Array –
S
(via MultiJson) - Boolean –
N
(1 for true and 0 for false) - Date –
N
(Integer, seconds since Epoch) - DateTime –
N
(Float, seconds since Epoch) - Float –
N
- Hash –
S
(via MultiJson) - Integer –
N
- Set –
SS
,NS
,BS
(Set of String, Number or AWS::DynamoDB::Binary) - String –
S
- Time –
N
(Float, seconds since Epoch)
Repository methods
See complete list of Repository methods provided by Lotus::Model
.
Following methods are not supported since it's incompatible with DynamoDB:
- first
- last
Query methods
Generic methods supported by DynamoDB adapter:
- all
- where (aliases:
eq
,in
,between
) - or
- exclude (aliases:
not
,ne
) - select
- order (alias:
asc
) - desc
- limit
- exists? (alias:
exist?
) - count
DynamoDB-specific methods:
- query – ensure
query
operation is performed instead ofscan
- consistent – require consistent read for query
- index – perform query on specific index
- le
- lt
- ge
- gt
- contains
- not_contains
- begins_with
- null
- not_null
Example
Check out the simple example in examples/purchase.rb.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request