{"id":13428883,"url":"https://github.com/frankfarrell/dynamodb-dsl","last_synced_at":"2025-06-30T21:36:56.015Z","repository":{"id":88518678,"uuid":"140305373","full_name":"frankfarrell/dynamodb-dsl","owner":"frankfarrell","description":"A collection of AWS DynamoDB utils written in Kotlin","archived":false,"fork":false,"pushed_at":"2018-08-22T09:50:43.000Z","size":105,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-28T10:14:31.289Z","etag":null,"topics":["dynamodb","kotlin-library","rxkotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/frankfarrell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-07-09T15:28:54.000Z","updated_at":"2022-12-06T20:09:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"b089dc4e-6e68-4956-9154-eaf1e14725f4","html_url":"https://github.com/frankfarrell/dynamodb-dsl","commit_stats":null,"previous_names":["frankfarrell/dynamodb-utils"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/frankfarrell/dynamodb-dsl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fdynamodb-dsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fdynamodb-dsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fdynamodb-dsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fdynamodb-dsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frankfarrell","download_url":"https://codeload.github.com/frankfarrell/dynamodb-dsl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frankfarrell%2Fdynamodb-dsl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262854772,"owners_count":23375187,"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":["dynamodb","kotlin-library","rxkotlin"],"created_at":"2024-07-31T01:01:07.758Z","updated_at":"2025-06-30T21:36:55.952Z","avatar_url":"https://github.com/frankfarrell.png","language":"Kotlin","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# dynamodb-utils\r\n\r\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7722315c9da948bc876aa6993d7e96bb)](https://www.codacy.com/app/frankfarrell/dynamo-batch?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=frankfarrell/dynamo-batch\u0026amp;utm_campaign=Badge_Grade)\r\n[![Build Status](https://travis-ci.org/frankfarrell/dynamodb-utils.svg?branch=master)](https://travis-ci.org/frankfarrell/dynamodb-utils)\r\n[![](https://jitpack.io/v/frankfarrell/dynamodb-utils.svg)](https://jitpack.io/#frankfarrell/dynamodb-utils)\r\n\r\nKotlin library with utility functions for AWS DynamDB. Run queries with the DSL, clone a table and do batch writes with exponential backoff. \r\n\r\n## Get it\r\n\r\nThe easiest thing is to use [jitpack](jitpack.io). Add this to your gradle file\r\n\r\n```groovy\r\nrepositories {\r\n    jcenter()\r\n    maven { url \"https://jitpack.io\" }\r\n}\r\ndependencies {\r\n    implementation 'com.github.frankfarrell:dynamodb-utils:0.0.2'\r\n}\r\n```\r\n\r\n## Dynamo DSL (Work in Progess)\r\nA kotlin internal DSL for Query, Scan and Update operations on Dynamo\r\n\r\n```kotlin\r\n\r\nvar result = DynamoDSL().query(\"mytable\") { \r\n            hashKey(\"myHashKey\") {\r\n                eq(\"abcd\")\r\n            }\r\n            sortKey(\"mysortkey\"){\r\n                between ( 2 AND 3)\r\n            }\r\n            filtering {\r\n                attribute(\"age\") {\r\n                    eq(44)\r\n                } and attributeExists(\"name\") or {\r\n                     attribute(\"nested\"){\r\n                         eq(\"x\")\r\n                     } and attributeExists(\"movie\"){\r\n                         eq(\"y\")\r\n                     }\r\n                }\r\n            }\r\n        }\r\n        \r\nwhile(result.hasNext()){\r\n    println(result.next());\r\n}\r\n```\r\n\r\n## DynamoBatchExecutor\r\n\r\nDynamoDB allows writing and deleting items in batches of up to 25. However if there is a provisioned throughput exception, some or all the requests may fail. \r\nThe aws sdk does not retry these requests transparently as it does for other operations, but it is left up the client to retry, ideally with exponential backoff. \r\nThis library does that for you using rx-kotlin. \r\n\r\nFailed writes are retried up until the attempt limit is reached using exponential backoff with jitter. \r\n\r\nFor reference, [github link to issue](https://github.com/aws/aws-sdk-js/issues/1262)\r\nFor details on exponential backoff and jitter in aws see [her](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/)\r\n\r\n### Examples\r\n```kotlin \r\n\r\ndata class Person(val name:String, val address: String)\r\n\r\nclass PersonMapper : DynamoMapper\u003cPerson\u003e {\r\n    override fun mapToDynamoItem(person: Person): Map\u003cString, AttributeValue\u003e {\r\n        return mapOf(Pair(\"name\", AttributeValue(person.name)),\r\n                Pair(\"address\", AttributeValue(person.address)))\r\n    }\r\n}\r\n\r\nval amazonDynamoDB: AmazonDynamoDB = ...\r\n\r\nval dyanmoBatch: DynamoBatchExecutor\u003cPerson\u003e = DynamoBatchExecutor\u003cPerson\u003e (amazonDynamoDB)\r\n\r\ndynamoBatch.persist(listOf(Person(\"bob\", \"France\"), Person(\"jack\", \"Dublin\")), PersonMapper(), \"targetTable\")\r\n\r\n```\r\n\r\n## DynamoTableCloner\r\n\r\nThis library allows you to clone a dynamo table, including hash and sort key,local and secondary indexes, provisioned throughput settings, dynamo streaming even source mappings and autoscaling properties if defined. \r\nThe library also exposes functions that return the aws sdk requests that would create all of the above without applying them so that tables can be partially cloned, and also streaming event sources or autoscaling properties from one table to \r\nbe applied to another \r\n\r\n### Examples\r\n```kotlin\r\n\r\n// You can create your own clients as necessary, the default is to use the standard client. \r\nval amazonDynamoDB: AmazonDynamoDB = ...\r\nval awsLambdaClient: AWSLambdaClient = ...\r\nval autoScalingClient: AWSApplicationAutoScaling = ...\r\n\r\nval dynamoTableCloner: DynamoTableCloner = DynamoTableCloner(amazonDynamoDB, awsLambdaClient, autoScalingClient)\r\n\r\ndynamoTableCloner.cloneTable(\"template\", \"target\")\r\n\r\n// You now have a new table called \"target\"\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankfarrell%2Fdynamodb-dsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrankfarrell%2Fdynamodb-dsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrankfarrell%2Fdynamodb-dsl/lists"}