module Minidynamo::Model::DynamoDBOverloads::ClassMethods
Public Instance Methods
convert_key_to_dynamo_db_types(key)
click to toggle source
# File lib/minidynamo/model/dynamo_db_overloads.rb, line 41 def convert_key_to_dynamo_db_types key keyname = key.keys[0] type = key[keyname] equivalent_type = nil case type when :float equivalent_type = :number when :integer equivalent_type = :number when :boolean equivalent_type = :number when :binary equivalent_type = :binary else equivalent_type = :string end key = {} key[keyname] = equivalent_type return key end
create_table()
click to toggle source
Changed: Don’t accept parameters when creating, use the declared options inside the model
# File lib/minidynamo/model/dynamo_db_overloads.rb, line 14 def create_table create_opts = {} create_opts[:hash_key] = convert_key_to_dynamo_db_types hash_key create_opts[:range_key] = convert_key_to_dynamo_db_types range_key if range_key dynamo_db.tables.create dynamo_db_table_name, read_capacity, write_capacity, create_opts end
dynamo_db_table(shard_name = nil)
click to toggle source
@return [DynamoDB::Table] changed to use hash key other than id @api private
# File lib/minidynamo/model/dynamo_db_overloads.rb, line 28 def dynamo_db_table shard_name = nil table = dynamo_db.tables[dynamo_db_table_name(shard_name)] table.hash_key = convert_key_to_dynamo_db_types(hash_key) #[:id, :string] table.range_key = convert_key_to_dynamo_db_types(range_key) if range_key #table.hash_key = {:public_token => :string } #table.range_key = {:created_at => :string } #table.hash_key = [:public_token, :string] #table.range_key = [:created_at, :string] table end