From d2faca97c617c7d7e18d408b842413493294d2eb Mon Sep 17 00:00:00 2001 From: Doug Kirk Date: Fri, 8 Jul 2016 11:32:00 -0500 Subject: [PATCH 1/3] Add support for update functions --- README.md | 2 +- project.clj | 2 +- src/com/ashafa/clutch.clj | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4553b99..6fa1434 100644 --- a/README.md +++ b/README.md @@ -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.4.1"] ``` Or, if you're using Maven, add this dependency to your `pom.xml`: diff --git a/project.clj b/project.clj index 9167ad0..bcafb70 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject com.ashafa/clutch "0.4.0" +(defproject com.ashafa/clutch "0.4.1" :description "A Clojure library for Apache CouchDB." :url "https://github.com/clojure-clutch/clutch/" :license {:name "BSD" diff --git a/src/com/ashafa/clutch.clj b/src/com/ashafa/clutch.clj index 40db01a..efc9ae8 100644 --- a/src/com/ashafa/clutch.clj +++ b/src/com/ashafa/clutch.clj @@ -389,6 +389,13 @@ (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)) + ;;;; _changes (defdbop changes From e8e83fcc153224250d709fa8e0ad07ac710330f5 Mon Sep 17 00:00:00 2001 From: Doug Kirk Date: Fri, 26 Aug 2016 14:12:54 -0500 Subject: [PATCH 2/3] update deps --- project.clj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/project.clj b/project.clj index bcafb70..8d9aa90 100644 --- a/project.clj +++ b/project.clj @@ -3,14 +3,14 @@ :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"] + [clj-http "3.1.0"] + [cheshire "5.6.3"] [commons-codec "1.6"] - [com.cemerick/url "0.0.6"] + [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 From b75d9ac9efd0d5d4156ac223975dc8e6db9293c8 Mon Sep 17 00:00:00 2001 From: Doug Kirk Date: Wed, 26 Oct 2016 16:15:28 -0500 Subject: [PATCH 3/3] Add support for fetching results from CouchDB list functions. --- README.md | 4 ++-- project.clj | 6 +++--- src/com/ashafa/clutch.clj | 11 ++++++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6fa1434..2553f3f 100644 --- a/README.md +++ b/README.md @@ -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.1"] +[com.ashafa/clutch "0.5.0"] ``` Or, if you're using Maven, add this dependency to your `pom.xml`: @@ -16,7 +16,7 @@ Or, if you're using Maven, add this dependency to your `pom.xml`: com.ashafa clutch - 0.4.0 + 0.5.0 ``` diff --git a/project.clj b/project.clj index 8d9aa90..26d92c4 100644 --- a/project.clj +++ b/project.clj @@ -1,13 +1,13 @@ -(defproject com.ashafa/clutch "0.4.1" +(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.8.0"] - [clj-http "3.1.0"] + [clj-http "3.3.0"] [cheshire "5.6.3"] - [commons-codec "1.6"] + [commons-codec "1.10"] [com.cemerick/url "0.1.1"] [org.clojure/clojurescript "1.8.40" :optional true diff --git a/src/com/ashafa/clutch.clj b/src/com/ashafa/clutch.clj index efc9ae8..2084132 100644 --- a/src/com/ashafa/clutch.clj +++ b/src/com/ashafa/clutch.clj @@ -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!))) @@ -396,6 +396,15 @@ (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