Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/com/ashafa/clutch.clj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@
:data {:source (str srcdb)
:target (str tgtdb)}))

(defdbop uuids
"Returns a list of n fresh UUID's from the server for use as id in future calls
to put-document. For the rationale behind preferring PUT requests with
pre-generated ids to POST requests when saving new documents, see
http://wiki.apache.org/couchdb/HTTP_Document_API."
[db n]
(couchdb-request :get
(->
(url/url db "/_uuids")
(assoc :query {:count n}))))

(def ^{:private true} byte-array-class (Class/forName "[B"))

(defn- attachment-info
Expand Down
4 changes: 4 additions & 0 deletions test/test_clutch.clj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@
(put-document (first test-docs) :id "some_id")
(failing-request 409 (put-document (first test-docs) :id "some_id")))

(defdbtest get-two-uuids
(let [resp (uuids 2)]
(is (= 2 (count (:uuids resp))))))

(defdbtest update-a-document
(let [id (:_id (put-document (nth test-docs 3)))]
(update-document (get-document id) {:email "[email protected]"})
Expand Down