Skip to content

Conversation

rafa0805
Copy link

@rafa0805 rafa0805 commented Jun 3, 2025

Added component to initialize AWS DynamoDB client.

Component initialization

(component/system-map
   :dynamo-db (tc.ddb.component/map->AwsDynamoDb {:credentials (when-not (= profile :prod)
                                                       create-dev-credentials)
                                        :endpoint (when-not (= profile :prod)
                                                    (URI. development-url))
                                        :region Region/AP_NORTHEAST_1}))

Getting item from DynamoDB table

(let [item (tc.ddb.protocol/get-item dynamo-db
                                     "example-table"
                                     {"email" (tc.ddb.fmt/clj-string->ddb-string "sample@example.com")})]

  ;; convert to clojure map if needed
  {:name (tc.ddb.fmt/ddb-string->clj-string (get item "name"))
   :age (tc.ddb.fmt/ddb-number->clj-int (get item "age"))})


(defprotocol IDynamoDb
(get-item [this table-name partition-key]) ; Get item from DynamoDB table using the provided partition key
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method to be added as needed.

@rafa0805 rafa0805 marked this pull request as ready for review June 3, 2025 05:19
@rafa0805 rafa0805 requested a review from syunta June 3, 2025 05:19
@rafa0805 rafa0805 force-pushed the add-dynamo-db-component branch from 31a4ff2 to ebe7477 Compare June 3, 2025 07:16
@rafa0805 rafa0805 force-pushed the add-dynamo-db-component branch from ebe7477 to 8e0610f Compare June 3, 2025 07:18
@rafa0805 rafa0805 force-pushed the add-dynamo-db-component branch from 9094946 to e326f69 Compare June 3, 2025 07:31
@rafa0805 rafa0805 closed this Jun 3, 2025
@rafa0805 rafa0805 deleted the add-dynamo-db-component branch June 3, 2025 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant