Skip to content

Commit

Permalink
Adds transactions to ddb namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
dehli committed Nov 28, 2019
1 parent 2a50b6e commit f591bad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>dehli</groupId>
<artifactId>serverless</artifactId>
<version>0.1.7</version>
<version>0.1.8</version>
<name>serverless</name>

<dependencies>
Expand Down
26 changes: 26 additions & 0 deletions src/serverless/aws/dynamo_db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@
(defn create-set [client values]
(js-invoke client "createSet" (clj->js values)))

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Transaction Actions
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn- transaction-action [key table-name options]
{key (merge {:TableName table-name} options)})

(defn condition-check-action [table-name options]
(transaction-action :ConditionCheck table-name options))

(defn delete-action [table-name options]
(transaction-action :Delete table-name options))

(defn put-action [table-name options]
(transaction-action :Put table-name options))

(defn update-action [table-name options]
(transaction-action :Update table-name options))

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Regular Actions
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn delete [client params]
(js-call client "delete" params))

Expand All @@ -46,5 +69,8 @@
(defn query [client params]
(js-call client "query" params))

(defn transact-write [client actions]
(js-call client "transactWrite" {:TransactItems actions}))

(defn update [client params]
(js-call client "update" params))

0 comments on commit f591bad

Please sign in to comment.