couchdb-conduit-0.10.2: Couch DB client library using http-conduit and aeson

Safe HaskellSafe-Infered

Database.CouchDB.Conduit.View.Query

Contents

Description

CouchDB View Query options.

For details see http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options. Note, because all options must be a proper URL encoded JSON, construction of complex parameters can be very tedious. To simplify this, use mkQuery.

Synopsis

Creating Query

data CouchQP Source

CouchDB Query options primitives.

Constructors

forall a . ToJSON a => QPComplex ByteString a

Complex view query parameter.

 couchQP [QPComplex "param" (["a", "b"] :: [String])]
 [("param", Just "[\"a\",\"b\"]")]
 ...?param=["a","b"]
 
 couchQP [QPComplex "key" (("a", 1) :: (String, Int))]
 [("key", Just "[\"a\",0]")]
 ...?param=["a",0]

It't just convert lazy ByteString from encode to strict ByteString. For more efficient use specific functions.

QPBS ByteString ByteString

Quoted ByteString query parameter.

 ...?param="value" 
QPInt ByteString Int

Int query parameter.

 ...?param=100 
QPBool ByteString Bool

Bool query parameter.

 ...?param=true
QPDescending

Reverse rows output.

 ...?descending=true 
QPLimit Int

Limit rows. Use Zero (0) to omit.

 ...?limit=5 
QPSkip Int

Skip rows. Use Zero (0) to omit.

 ...?skip=10
QPStale Bool

Stale view. On True sets stale parameter to ok, else sets it to update_after.

 ...?stale=ok
 ...?stale=update_after
forall a . ToJSON a => QPKey a

key query parameter.

 ...?key=...
forall a . ToJSON a => QPStartKey a

Row key to start with. Becomes endkey if descending turned on. See couchQuery.

 ...?startkey=...
 ...?descending=true?endkey=...
forall a . ToJSON a => QPEndKey a

Row key to start with. Becomes startkey if descending turned on. See couchQuery.

 ...?endkey=...
 ...?descending=true?startkey=...
forall a . ToJSON a => QPKeys a

Row key to start with. Use only with couchView and couchView_. For large sets of keys use couchViewPost and couchViewPost_

 ...?keys=...
QPGroup

Turn on grouping.

 ...?group=true
QPGroupLevel Int

Set grouping level. Use Zero (0) to omit.

 ...?group_level=2
QPReduce Bool

Control reduce.

 ...?reduce=true
 ...?reduce=false
QPIncludeDocs

Turn on inclusion docs in view results.

 ...?include_docs=true
QPInclusiveEnd

Turn off inclusion endkey in view results.

 ...?inclusive_end=false
QPUpdateSeq

Response includes an update_seq value indicating which sequence id of the database the view reflects

 ...?update_seq=true
QPStartKeyDocId Path

Document id to start with.

 ...?startkey_docid=...
QPEndKeyDocId Path

Document id to end with.

 ...?endkey_docid=...

mkQuerySource

Arguments

:: [CouchQP]

Query options.

-> Query 

Make CouchDB query options.

Parameter helpers

qpUnit :: HashMap ByteString BoolSource

Returns empty HashMap. Aeson will convert this to {} (JSON unit). This useful for startkey and endkey.

 couchQuery [QPStartKey (1, 0), QPEndKey (1, {})]

qpNull :: ValueSource

Simply return Null.