Sha256: 59f36dd8995d9e6abc3fce9a5f4776bab385450e160eb4ca8410ed9e6e9a726e
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
# DynaModel AWS DynamoDB ORM for Rails based on AWS::Record in the aws-sdk gem. Still a work in progress but very functional. ## Installation ``` gem 'dyna_model' ``` ## Sample Model ``` class Dude include DynaModel::Document string_attr :hashy integer_attr :ranger, default_value: 2 string_attr :name, default_value: lambda { "dude" } boolean_attr :is_dude datetime_attr :born serialized_attr :cereal timestamps hash_key :hashy range_key :ranger set_shard_name "usery" local_secondary_index :name global_secondary_index(:name_index, { hash_key: :name, projection: [:name] }) read_provision 4 write_provision 4 guid_delimiter "!" validates_presence_of :name before_create :do_something before_validation on: :create do do_something end end ``` ## Sample Methods ``` # Read a single object by Hash and (optionally) Range keys Dude.read # Query by Hash and (optionally) Range keys (compatible with Local and Global Secondary Indexes) Dude.read_range # Batch read Dude.read_multiple # Read by guid (helper for hash + guid_delimiter + range) Dude.read_guid # Get count of query Dude.count_range # Table scan with more complex filters Dude.scan # Create Table Dude.create_table # Delete Table Dude.delete_table # Rake tasks rake ddb:create CLASS=Dude rake ddb:create CLASS=all rake ddb:destroy CLASS=Dude rake ddb:destroy CLASS=all ``` ## Elasticsearch::Model compatible adapter ``` require 'dyna_model/adapters/elasticsearch/dyna_model_adapter' class Item include DynaModel::Document include Elasticsearch::Model include Elasticsearch::Model::Callbacks end ``` # AWS::Record * http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/Record.html * https://github.com/aws/aws-sdk-ruby/blob/master/lib/aws/record/abstract_base.rb
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dyna_model-0.0.2 | README.md |