From b6697b4bfdc0ff0636855de09081102486f19a35 Mon Sep 17 00:00:00 2001 From: Doug Kirk Date: Wed, 26 Oct 2016 16:15:28 -0500 Subject: [PATCH] Add support for fetching results from CouchDB list functions. --- project.clj | 6 +++--- src/com/ashafa/clutch.clj | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) 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