Skip to content

Commit

Permalink
changed format for key in update-item and bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
surt666 committed May 14, 2012
1 parent c442488 commit c28f23d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
16 changes: 8 additions & 8 deletions README.md
Expand Up @@ -45,25 +45,25 @@ protocol=https

(update-item client "table" "hash-key" {:value [1 "add"]})
(update-item client "table" "hash-key" {:value [1 "add"]} "range-key")
(update-item client "table" ["hash-key" "range-key"] {:value [1 "add"]})

(scan client "table")

(scan client "table" [["author" "eq" "steen"]] [:attr])

(find-items client "table" "NORMAL" true)
(find-items client "table" "hash-key" true)

(find-items client "table" "NORMAL" true ["between" 715 815])
(find-items client "table" "hash-key" true ["between" 715 815])

(find-items client "table" "NORMAL" true ["between" 715 815] [:attr1 :attr2])
(find-items client "table" "hash-key" true ["between" 715 815] [:attr1 :attr2])

(find-items client "table" "NORMAL" true ["between" 715 815] [:attr1 :attr2] false)
(find-items client "table" "hash-key" true ["between" 715 815] [:attr1 :attr2] false)

(find-items client "table" "NORMAL" true ["between" 715 815] [:attr1 :attr2] false 1)
(find-items client "table" "hash-key" true ["between" 715 815] [:attr1 :attr2] false 1)

(find-items client "table" "NORMAL" true ["between" 715 815] [:attr1 :attr2] false 1 "hash")
(find-items client "table" "hash-key" true ["between" 715 815] [:attr1 :attr2] false 1 "hash")

(find-items client "table" "NORMAL" true ["between" 715 815] [:attr1 :attr2] false 1 ["hash" "range"])
(find-items client "table" "hash-key" true ["between" 715 815] [:attr1 :attr2] false 1 ["hash" "range"])

(batch-write client {:table1 [{:id \"foo1\" :key \"bar1\"} {:id \"foo2\" :key \"bar2\"}] :table2 [{:id2 \"foo1\" :key2 \"bar1\"} {:id2 \"foo2\" :key2 \"bar2\"}]})

Expand Down
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject dynamo4clj "1.0.8"
(defproject dynamo4clj "1.0.9"
:description "Amazon DynamoDB API"
:dependencies [[org.clojure/clojure "1.4.0"]
[com.amazonaws/aws-java-sdk "1.3.8"]
Expand Down
7 changes: 4 additions & 3 deletions src/dynamo4clj/core.clj
Expand Up @@ -152,9 +152,10 @@
(with-meta (if attr (keywordize-keys (to-map attr)) {}) {:consumed-capacity-units (.getConsumedCapacityUnits pres)})))


(defn update-item [client table hash-key attr & [range-key]]
"Update item (map) in table with optional attributes"
(let [key (if range-key (item-key-range hash-key range-key) (item-key hash-key))
(defn update-item [client table key attr]
"Update item (map) in table with optional attributes.
Key is either a string (hashkey), or a tuple [hashkey rangekey]"
(let [key (if (vector? key) (item-key-range (get key 0) (get key 1)) (item-key key))
attrupd (fmap to-attr-value-update (stringify-keys attr))
req (doto (UpdateItemRequest.) (.withTableName table) (.withKey key) (.withReturnValues ReturnValue/ALL_NEW) (.withAttributeUpdates attrupd))
ures (. (refresh-client client) (updateItem req))]
Expand Down

0 comments on commit c28f23d

Please sign in to comment.