Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for update functions #90

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Clutch is a [Clojure](http://clojure.org) library for [Apache CouchDB](http://co
To include Clutch in your project, simply add the following to your `project.clj` dependencies:

```clojure
[com.ashafa/clutch "0.4.0"]
[com.ashafa/clutch "0.5.0"]
```

Or, if you're using Maven, add this dependency to your `pom.xml`:
Expand All @@ -16,7 +16,7 @@ Or, if you're using Maven, add this dependency to your `pom.xml`:
<dependency>
<groupId>com.ashafa</groupId>
<artifactId>clutch</artifactId>
<version>0.4.0</version>
<version>0.5.0</version>
</dependency>
```

Expand Down
14 changes: 7 additions & 7 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
(defproject com.ashafa/clutch "0.4.0"
(defproject com.ashafa/clutch "0.5.0"
:description "A Clojure library for Apache CouchDB."
:url "https://github.com/clojure-clutch/clutch/"
:license {:name "BSD"
:url "http://www.opensource.org/licenses/BSD-3-Clause"}
:dependencies [[org.clojure/clojure "1.4.0"]
:dependencies [[org.clojure/clojure "1.8.0"]

[clj-http "0.5.5"]
[cheshire "4.0.0"]
[commons-codec "1.6"]
[com.cemerick/url "0.0.6"]
[clj-http "3.3.0"]
[cheshire "5.6.3"]
[commons-codec "1.10"]
[com.cemerick/url "0.1.1"]

[org.clojure/clojurescript "0.0-1450" :optional true
[org.clojure/clojurescript "1.8.40" :optional true
:exclusions [com.google.code.findbugs/jsr305
com.googlecode.jarjar/jarjar
junit
Expand Down
18 changes: 17 additions & 1 deletion src/com/ashafa/clutch.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
[cheshire.core :as json]
[clojure.java.io :as io]
[cemerick.url :as url]
[com.ashafa.clutch.http-client :refer :all]
clojure.string)
(:use com.ashafa.clutch.http-client)
(:import (java.io File FileInputStream BufferedInputStream InputStream ByteArrayOutputStream)
(java.net URL))
(:refer-clojure :exclude (conj! assoc! dissoc!)))
Expand Down Expand Up @@ -389,6 +389,22 @@
(utils/url attachment-name)
(assoc :as :stream))))))

(defdbop run-update-fn
"Runs a CouchDB update function."
[db design-document update-function-name body & {:keys [id]}]
(couchdb-request (if id :put :post)
(utils/url db "_design" (name design-document) "_update" (name update-function-name) id)
:data body))

(defdbop get-list
"Get list views associated with a design document.
Also takes an optional map for querying options.

No support for views in design documents other than the one containing the list view."
[db design-document list-key view-key & [query-params-map]]
(let [url (assoc (utils/url db "_design" (name design-document) "_list" (name list-key) (name view-key))
:query query-params-map)]
(couchdb-request :get url)))
;;;; _changes

(defdbop changes
Expand Down