{"id":20904668,"url":"https://github.com/sage/dynamodb_framework","last_synced_at":"2025-05-13T05:30:47.722Z","repository":{"id":47006499,"uuid":"54202040","full_name":"Sage/dynamodb_framework","owner":"Sage","description":null,"archived":false,"fork":false,"pushed_at":"2021-09-17T16:08:40.000Z","size":155,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-04-18T00:38:31.545Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-18T13:12:22.000Z","updated_at":"2023-12-21T17:43:32.000Z","dependencies_parsed_at":"2022-09-17T14:00:19.036Z","dependency_job_id":null,"html_url":"https://github.com/Sage/dynamodb_framework","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fdynamodb_framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fdynamodb_framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fdynamodb_framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sage%2Fdynamodb_framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sage","download_url":"https://codeload.github.com/Sage/dynamodb_framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253882709,"owners_count":21978540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T13:18:26.858Z","updated_at":"2025-05-13T05:30:47.294Z","avatar_url":"https://github.com/Sage.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DynamoDb_Framework\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/068ca2a25a441119af70/maintainability)](https://codeclimate.com/github/Sage/dynamodb_framework/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/068ca2a25a441119af70/test_coverage)](https://codeclimate.com/github/Sage/dynamodb_framework/test_coverage)\n[![Gem Version](https://badge.fury.io/rb/dynamodb_framework.svg)](https://badge.fury.io/rb/dynamodb_framework)\n\nWelcome to DynamoDb_Framework, this is a light weight framework that provides managers to help with interacting with aws dynamodb.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'dynamodb_framework'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install dynamodb_framework\n\n## Usage\n\n##Global Config\n\n### #namespace\nThe namespace is used to set the prefix applied to all table and index names.\n\n    DynamoDbFramework.namespace = 'uat'\n\n\u003e With a namespace of 'uat' and a table name of 'people', the resulting table name would be 'uat.people'\n\n### #namespace_delimiter\nThis is the delimiter used to join the namespace prefix to table/index names.\n\n\u003e DEFAULT = '.'\n\n    DynamoDbFramework.namespace_delimiter = '-'\n\n### #default_store\nThis is used to set the default store that should be used for all connection actions that don't specify a store override.\n\n    DynamoDbFramework.default_store = store\n\n\u003e If no [DynamoDbFramework::Store] is manually specified then the default store will attempt to use the aws credentials from the host machines aws configuration profile.\n\n# Table\nBefore you can work with any data in dynamodb you require a table definition.\nTo define a table create a class and use the `DynamoDbFramework::Table` module.\n\n    class ExampleTable\n      extend DynamoDbFramework::Table\n\n      table_name 'example'\n      partition_key :id, :S\n      range_key :timestamp, :N\n\n    end\n\n**attributes**\n\n - **table_name** [String] [Required] This is used to specify the name of the table.\n - **partition_key** [Symbol, Symbol] [Required] This is used to specify the item field to use for the partition key, along with the type of the field.\n - **range_key** [Symbol, Symbol] [Optional] This is used to specify the item field to use for the range key, along with the type of the field.\n\nThis definition can then be used to interact with DynamoDb in relation to the table.\n\n## #create\nThis method is called create the table definition within a dynamodb account.\n\u003e This method should operate in an idempotent manner.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Required] This is used to specify the Dynamodb instance/account to connect to.\n - **read_capacity** [Integer] [Optional] [Default=25] This is used to specify the read capacity to provision for this table.\n - **write_capacity** [Integer] [Optional] [Default=25] This is used to specify the write capacity to provision for this table.\n - **indexes** [Array] [Optional] This is used to specify an array of Index definitions to be created with the table.\n\n\n    ExampleTable.create(read_capacity: 50, write_capacity: 35, indexes: [ExampleIndex])\n\n## #update\nThis method is called to update the provisioned capacity for the table.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n - **read_capacity** [Integer] [Required] This is used to specify the read capacity to provision for this table.\n - **write_capacity** [Integer] [Required] This is used to specify the write capacity to provision for this table.\n\n\n    ExampleTable.update(read_capacity: 100, write_capacity: 50)\n\n## #drop\nThis method is called to drop the table from a dynamodb account.\n\u003e This method should operate in an idempotent manner.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n\n\n    ExampleTable.drop\n\n\n## #exists?\nThis method is called to determine if this table exists in a dynamodb account.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n\n\n    ExampleTable.exists?\n\n## #get_item\nThis method is called to get a single item from the table by its unique key.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n - **partition** [object] [Required] This is used to specify the partition_key value of the item to get.\n - **range** [object] [Optional] This is used to specify the range_key value of the item to get.\n\n\n    ExampleTable.get_item(partition: uuid, range: timestamp)\n\n\n## #put_item\nThis method is called to put a single item into the table.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n - **item** [object] [Required] This is the item to store in the table.\n\n\n    ExampleTable.put_item(item: item)\n\n\n## #delete_item\nThis method is called to delete an item from the table.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n - **partition** [object] [Required] This is used to specify the partition_key value of the item.\n - **range** [object] [Optional] This is used to specify the range_key value of the item.\n\n\n    ExampleTable.delete_item(partition: uuid, range: timestamp)\n\n\n## #all\nThis method is called to return all items from the table.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n\n    ExampleTable.all\n\n\n## #query\nThis method is called to query the table for a collection of items.\n\n**Params**\n\n - **partition** [object] [Required] This is used to specify the partition_key to query within.\n\nThe query is then built up using method chaining e.g:\n\n    query = ExampleTable.query(partition: partition_value).name.eq('fred').and.age.gt(18)\n\nThe above query chain translates into:\n\n    FROM partition_value WHERE name == 'fred' AND age \u003e 18\n\nTo execute the query you can then call `#execute` on the query:\n\n    query.execute\n\n### #execute\nThis method is called to execute a query.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n - **limit** [Integer] [Optional] This is used to specify a limit to the number of items returned by the query.\n - **count** [Boolean] [Optional] This is used to specify if the query should just return a count of results.\n\n## Query expressions\n\n### #eq(value)\nThis method is used to specify the `==` operator within a query.\n\n### #not_eq(value)\nThis method is called to specify the `!=` operator within a query.\n\n### #gt(value)\nThis method is called to specify the `\u003e` operator within a query.\n\n### #gt_eq(vaue)\nThis method is called to specify the `\u003e=` operator within a query.\n\n### #lt(value)\nThis method is called to specify the `\u003c` operator within a query.\n\n### #lt_eq(value)\nThis method is called to specify the `\u003c=` operator within a query.\n\n### #contains(value)\nThis method is called to check if a field contains a value within a query.\n\n### #exists?\nThis method is called to check if a field exists within a query.\n\n### #and\nThis method is called to combine conditions together in a traditional `\u0026\u0026` method within a query.\n\n### #or\nThis method is called to combine conditions together in a traditional `||` method within a query.\n\n# Index\nTo define a global secondary index in dynamodb create an index definition class that extends from the `DynamoDbFramework::Index` module.\n\n    class ExampleIndex\n      extend DynamoDbFramework::Index\n\n      index_name 'example_index'\n      table ExampleTable\n      partition_key :name, :S\n      range_key :id, :S\n\n    end\n\n**attributes**\n\n - **index_name** [String] [Required] This is used to specify the name of the index.\n - **table** [Table] [Required] This is the table definition class for the table the index should be applied to.\n - **partition_key** [Symbol, Symbol] [Required] This is used to specify the item field to use for the partition key, along with the type of the field.\n - **range_key** [Symbol, Symbol] [Optional] This is used to specify the item field to use for the range key, along with the type of the field.\n\n\n## #create\nThis method is called create the index definition within a dynamodb account.\n\u003e This method should operate in an idempotent manner.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n - **read_capacity** [Integer] [Optional] [Default=25] This is used to specify the read capacity to provision for this index.\n - **write_capacity** [Integer] [Optional] [Default=25] This is used to specify the write capacity to provision for this index.\n\n\n    ExampleIndex.create(read_capacity: 50, write_capacity: 35)\n\n## #update\nThis method is called to update the provisioned capacity for the index.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n - **read_capacity** [Integer] [Required] This is used to specify the read capacity to provision for this index.\n - **write_capacity** [Integer] [Required] This is used to specify the write capacity to provision for this index.\n\n\n    ExampleIndex.update(read_capacity: 100, write_capacity: 50)\n\n## #drop\nThis method is called to drop the current index.\n\u003e This method should operate in an idempotent manner.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n\n\n    ExampleIndex.drop\n\n## #exists?\nThis method is called to determine if this index exists in a dynamodb account.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n\n\n    ExampleIndex.exists?\n\n\n## #query\nThis method is called to query the index for a collection of items.\n\n**Params**\n\n - **partition** [object] [Required] This is used to specify the partition_key to query within.\n\nThe query is then built up using method chaining e.g:\n\n    query = ExampleIndex.query(partition: partition_value).gender.eq('male').and.age.gt(18)\n\nThe above query chain translates into:\n\n    FROM partition_value WHERE gender == 'male' AND age \u003e 18\n\nTo execute the query you can then call `#execute` on the query:\n\n    query.execute\n\n### #execute\nThis method is called to execute a query.\n\n**Params**\n\n - **store** [DynamoDbFramework::Store] [Optional] This is used to specify the Dynamodb instance/account to connect to. If not specified the `DyanmoDbFramework.default_store` will be used.\n - **limit** [Integer] [Optional] This is used to specify a limit to the number of items returned by the query.\n - **count** [Boolean] [Optional] This is used to specify if the query should just return a count of results.\n\n## Query expressions\n\n### #eq(value)\nThis method is used to specify the `==` operator within a query.\n\n### #not_eq(value)\nThis method is called to specify the `!=` operator within a query.\n\n### #gt(value)\nThis method is called to specify the `\u003e` operator within a query.\n\n### #gt_eq(vaue)\nThis method is called to specify the `\u003e=` operator within a query.\n\n### #lt(value)\nThis method is called to specify the `\u003c` operator within a query.\n\n### #lt_eq(value)\nThis method is called to specify the `\u003c=` operator within a query.\n\n### #contains(value)\nThis method is called to check if a field contains a value within a query.\n\n### #exists?\nThis method is called to check if a field exists within a query.\n\n### #and\nThis method is called to combine conditions together in a traditional `\u0026\u0026` method within a query.\n\n### #or\nThis method is called to combine conditions together in a traditional `||` method within a query.\n\n\n# MigrationScripts\nTo create or modify a DynamoDb instance you first need to create a migration script:\n\n**Example**\n\n    class CreateEventTrackingTableScript \u003c DynamoDbFramework::MigrationScript\n\n\t\tdef initialize\n\t\t\t#set the timestamp for when this script was created\n\t\t\t@timestamp = '20160318110710'\n\t\tend\n\n\t\tdef apply\n\t\t\tEventTrackingTable.create(read_capacity: 50, write_capacity: 35)\n\t\tend\n\t\tdef undo\n\t\t\tEventTrackingTable.drop\n\t\tend\n\tend\n\nEach migration script should have a unique fixed timestamp value of the following format:\n\n    yyyymmddhhMMss\n\n**Example**\n\n11:07:10 18-03-2016 would be:\n\n    20160318110710\n\nThis timestamp is used to track installation of each migration script and insure correct apply/undo ordering.\n\n# DynamoDbFramework::Namespace::MigrationManager\nThis manager is called to apply/rollback migration script changes against a DynamoDb instance.\n\n### #connect\nThis method is called to connect the manager to the DynamoDb instance. If the migration manager has never been connected to the instance then the 'dynamodb_migrations' table will be created to record migration script executions.\n\n    manager = DynamoDbFramework::MigrationManager.new\n    manager.connect\n\n### #apply\nThis method is called to execute any migration scripts (in chronological order) that have not been executed against the current DynamoDb instance.\n\n**Params**\n\n - **namespace** [String] [Required] This is used to specify the namespace for all migration scripts to be executed within.\n\n\n    #apply any outstanding migration scripts\n    manager.apply(namespace)\n\n### #rollback\nThis method is called to rollback the last migration script that was executed against the current DynamoDb instance.\n\n**Params**\n\n - **namespace** [String] [Required] This is used to specify the namespace for all migration scripts to be executed within.\n\n\n    #rollback the last migration script\n    manager.rollback(namespace)\n\n# DynamoDbFramework::TableManager\n\nThis manager object provides the following methods for managing tables within a DynamoDb instance.\n\u003e NOTE: This functionality should now be handled via the DynamoDbFramework::Table \u0026 DynamoDbFramework::Index module as described above.\n\n### #create\n\nThis method is called to create a table within DynamoDb.\n\n**Params**\n\n - **table_name** [String] [Required] This is used to specify the name of the table to create. (Must be unique within the DynamoDb instance).\n - **attributes** [Hash] [Required] This is used to specify the attributes used by the keys and indexes. (Use the DynamoDbFramework::AttributesBuilder to create attributes)\n - **partition_key** [Symbol] [Required] This is the document attribute that will be used as the partition key of this table.\n - **range_key** [Symbol / nil] [Optional] This is the document attribute that will be used as the range key for this table.\n - **read_capacity** [Number] [Default=20] This is the read throughput required for this table.\n - **write_capacity** [Number] [Default=10] This is the write throughput required for this table.\n - **global_indexes** [Array / nil] [Optional] This is an array of the global indexes to create for this table. (Use the ***#create_global_index*** method to create each global index required and populate an array for this parameter).\n\n**Examples**\n\nTable with partition key, no range key and no indexes:\n\n    #create an attribute builder\n\tbuilder = DynamoDbFramework::AttributesBuilder.new\n\n\t#set the partition key attribute\n\tbuilder.add(:type, :S)\n\n\t#create the table\n\tmanager.create('event_tracking', builder.attributes, :type)\n\nTable with partition key, range key and no indexes:\n\n    #create an attribute builder\n\tbuilder = DynamoDbFramework::AttributesBuilder.new\n\n\t#set the partition key attribute\n\tbuilder.add(:type, :S)\n\t#set the range key attribute\n\tbuilder.add(:timestamp, :S)\n\n\t#create the table\n\tmanager.create('event_tracking', builder.attributes, :type, :timestamp)\n\nTable with a global index:\n\n    #create an attribute builder\n\tbuilder = DynamoDbFramework::AttributesBuilder.new\n\n\t#set the partition key attribute\n\tbuilder.add(:id, :S)\n\n\tglobal_indexes = []\n\t#create the global index\n\tindex = manager.create_global_index('type_index', :type)\n\t#add the index to the global_indexes array\n\tglobal_indexes.push(index)\n\n\t#create the table and the index\n\tmanager.create('event_tracking', builder.attributes, :id, :nil, 20, 10, global_indexes)\n\n### #drop\nThis method is called to drop a table.\n\n\u003e **WARNING**: *This will drop all data stored within the table*\n\n**Params**\n\n - **table_name** [String] [Required] This is the name of the table to drop.\n\n**Example**\n\n    #drop the table\n    manager.drop('event_tracking')\n\n### #exists?(table_name)\n\nThis method is called to check if a table exists within the database.\n\n    manager.exists?('event_tracking')\n    =\u003e true\n\n\n### #add_index\nThis method is called to add an index to an existing table.\n\n**Params**\n\n - **table_name** [String] [Required] This is the name of the index. (Must be unique within the scope of the table)\n - **attributes** [Hash] [Required] This is the document attributes used by the table keys and index keys. (Use the DynamoDbFramework::AttributesBuilder to create the attributes hash.)\n - **global_index** [Hash] [Required] This is the global index to add to the table. (Use the ***#create_global_index*** method to create the global index hash.)\n\n**Example**\n\n\t#build the attributes hash\n\tbuilder = DynamoDbFramework::AttributesBuilder.new\n\t#add the attribute for the tables partition key \u0026 range key (if range key required)\n\tbuilder.add(:id, :S)\n\t#add the attributes for the index partition key and range key (if required)\n\tbuilder.add(:type, :S)\n\n    #create the index hash\n    index = manager.create_global_index('type_index', :type)\n\n    #add the index to the table\n    manager.add_index('event_tracking', builder.attributes, index)\n\n\n### #drop_index\nThis method is called to drop an existing index from a table.\n\n**Params**\n\n - **table_name** [String] [Required] This is the name of the table you want to remove the index from.\n - **index_name** [String] [Required] This is the name of the index you want to remove.\n\n**Example**\n\n\t#drop the index\n    manager.drop_index('event_tracking', 'type_index')\n\n### #update_index_throughput\n\nThis method is called to update the throughput required by an index.\n\n**Params**\n\n - **table_name** [String] [Required] This is the name of the table the index belongs to.\n - **index_name** [String] [Required] This is the name of the index to update.\n - **read_capacity** [Number] [Required] This is the read throughput required per second.\n - **write_capacity** [Number] [Required] This is the write throughput required per second.\n\n**Example**\n\n    #update the index\n    manager.update_index_throughput('event_tracking', 'type_index', 50, 20)\n\n### #update_ttl_attribute\n\nThis method is called to update the ttl attribute of a table.\n\n**Params** \n\n - **table_name** [String] [Required] This is the name of the table the attribute belongs to.\n - **enabled** [Boolean] [Required] This is true to turn TTL on the table or false to turn it off.\n - **attribute_name** [String] [Required] This is the name of the attribute that is going to be used for TTL.\n\n**Example**\n        #Enable TTL\n    update_ttl_attribute('ttl_example', true, 'ttl_timestamp')\n\n### #get_ttl_status\n\nThis method is called to get the ttl status of a table.\n\n**Params**\n\n- **table_name** [String] [Required] This is the name of the table being checked.\n\n**Example**\n        #Check TTL\n    get_ttl_status('ttl_example')\n    =\u003e {\n            time_to_live_status: \"ENABLED\",\n            attribute_name: \"ttl_date\"\n        }\n\n### #has_index?(table_name, index_name)\n\nThis method is called to check if an index exists on a table within the database.\n\n    manager.has_index?('event_tracking', 'event_type')\n    =\u003e true\n\n\n# DynamoDbFramework::Repository\n\nThis is a base repository that exposes core functionality for interacting with a DynamoDb table. It is intended to be wrapped inside of a table specific repository, and is only provided to give a common way of interacting with a DynamoDb table.\n\n\u003e NOTE: This functionality should now be handled via a DynamoDbFramework::Table or DynamoDbFramework::Index as detailed above.\n\nBefore calling any methods from the repository the **.table_name** attribute must be set so that the repository knows which table to run the operations against.\n\n**Example**\n\n    repository.table_name = 'event_tracking'\n\n### #put\nThis method is called to insert an item into a DynamoDb table.\n\n*Note*:\n\n         [DateTime] attributes will be stored as an ISO8601 string\n\n         [Time] attributes will be stored as an Epoch Int\n\nThe intent is that if you need to sort in dynamo by dates, then make sure you use a [Time] type. The Epoch int allows\nyou to compare properly as comparing date strings are not reliable.\n\n**Params**\n\n - **item** [Object] [Required] The document to store within the table.\n\n**Example**\n\n    #add the document object to the table\n    repository.put(item)\n\n### #delete\n\nThis method is called to delete a document from a DynamoDb table.\n\n**Params**\n\n - **keys** [Hash] [Required] This is a hash of the primary key of the document you want to delete. (The keys hash should contain the partition_key and if the table requires it the range_key.)\n\n**Example**\n\n    #delete an item where the partition key (:id) is the primary key\n    repository.delete({ :id =\u003e '012' })\n\n\t#delete an item where the partition key (:type) and the range key (:index) is the primary key\n\trepository.delete({ :type =\u003e 'list', :index =\u003e 2 })\n\n### #get_by_key\nThis method is called to get a single item from a table by its key.\n\n**Params**\n\n - **partition_key** [Symbol] [Required] This is the document attribute that is the partition key for the table.\n - **partition_key_value** [String / Number] [Required] This is the value of the documents partition key.\n - **range_key** [Symbol] [Optional] This is the document attribute that is the range key for the table.\n - **range_key_value** [String / Number] [Optional] This is the value of the documents range key.\n\n**Example**\n\n    #get an item where the partition key is the primary key\n    item = repository.get(:id, '12345')\n\n\t#get an item where the partition key and the range key is the primary key\n\titem = repository.get(:type, 'list', :index, 2)\n\n\n### #all\nThis method is called to get all items from a table.\n\n**Example**\n\n\n    #get all items from table\n    all_items_array = repository.all\n\n### #scan\nThis method is called to execute a query against an entire table bypassing any indexes.\n\n\u003e **WARNING:** *Full table scans are slower than queries ran against a global index.*\n\n**Params**\n\n - **expression** [String] [Required] This is an expression string for that contains the filter expression to run against the full table scan.\n - **expression_params** [Hash] [Required] This is a hash that contains the parameter names \u0026 values used by parameters within the scan expression.\n - **limit** [Number] [Optional] This is used to specify a limit to the number of records returned by the scan query.\n - **count** [Bool] [Optional] This is used to specify that the scan query should only return a count of the items that match the scan query.\n\n**Example**\n\n    #scan the table and return matching items\n    results = repository.scan('#type = :type and #index \u003e :index', { '#type' =\u003e :type, ':type' =\u003e 'list', '#index' =\u003e :index, ':index' =\u003e 2 })\n\n    #scan the table and return matching items limited to 5 results\n    results = repository.scan('#type = :type and #index \u003e :index', { '#type' =\u003e :type, ':type' =\u003e 'list', '#index' =\u003e :index, ':index' =\u003e 2 }, 5)\n\n    #scan the table and return a count of matching items\n    count = repository.scan('#type = :type and #index \u003e :index', { '#type' =\u003e :type, ':type' =\u003e 'list', '#index' =\u003e :index, ':index' =\u003e 2 }, nil, true)\n\n\u003e **Notes:**\n\u003e\n\u003e Attribute names should be specified using Expression parameter names which should start with a #\n\u003e\n\u003e Attribute values should be specified using Expression parameter values which should start with a :\n\n\n### #query\nThis method is called to execute a query against either a table partition or an index.\n\n**Params**\n\n - **partition_key_name** [Symbol] [Required] This is used to specify the attribute that is used as the partition key for this table.\n - **partition_key_value** [String / Number] [Required] This is used to specify the value of the partition to run this query against.\n - **range_key_name** [Symbol] [Optional] This is used to specify the range key to run this query against if needed.\n - **range_key_value** [String / Number] [Optional] This is used to specify the value of the range key to run this query against if needed.\n - **expression** [String] [Required] This is an expression string used to specify the filter  to run against the records found within the partition/range.\n - **expression_params** [Hash] [Required] This is a hash that contains the parameter names \u0026 values used by parameters within the query expression.\n - **index_name** [String] [Optional] This is the name of the index to run this query against.\n - **limit** [Number] [Optional] This is used to specify a limit to the number of records returned by the query.\n - **count** [Bool] [Optional] This is used to specify that the scan query should only return a count of the items that match the query.\n\n**Examples**\n\n Query from a table partition without an index:\n\n    results = repository.query(:name, 'name 1', nil, nil, '#number \u003e :number', { '#number' =\u003e 'number', ':number' =\u003e 2})\n\nQuery and Count from a table partition without an index:\n\n    count = repository.query(:name, 'name 1', nil, nil, '#number \u003e :number', { '#number' =\u003e 'number', ':number' =\u003e 2}, nil, nil, true)\n\nQuery from an index partition:\n\n    results = repository.query(:name, 'name 1', nil, nil, '#number \u003e :number', { '#number' =\u003e 'number', ':number' =\u003e 2}, 'name_index')\n\n\u003e **Notes:**\n\u003e\n\u003e Attribute names should be specified using Expression parameter names which should start with a #\n\u003e\n\u003e Attribute values should be specified using Expression parameter values which should start with a :\n\n## Testing\n\nTo run the tests locally, we use Docker to provide both a Ruby and JRuby environment along with a reliable Redis container.\n\n### Setup Images:\n\n\u003e This builds the Ruby docker image.\n\n```bash\ncd script\n./setup.sh\n```\n\n### Run Tests:\n\n\u003e This executes the test suite.\n\n```bash\ncd script\n./test.sh\n```\n\n### Cleanup\n\n\u003e This is used to clean down docker image created in the setup script.\n\n```bash\ncd script\n./cleanup.sh\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/sage/dynamodb_framework. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThis gem is available as open source under the terms of the\n[MIT licence](LICENSE).\n\nCopyright (c) 2018 Sage Group Plc. All rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsage%2Fdynamodb_framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsage%2Fdynamodb_framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsage%2Fdynamodb_framework/lists"}