couch-simple-0.0.1.0: A modern, lightweight, complete client for CouchDB

CopyrightCopyright (c) 2015, Michael Alan Dorman
LicenseMIT
Maintainermdorman@jaunder.io
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Database.Couch.Explicit.Design

Contents

Description

This module is intended to be import qualified. No attempt has been made to keep names of types or functions from clashing with obvious or otherwise commonly-used names, or even other modules within this package.

The functions here are derived from (and presented in the same order as) the Design Document API documentation. For each function, we attempt to link back to the original documentation, as well as make a notation as to how complete and correct we feel our implementation is.

Each function takes a Context---which, among other things, holds the name of the database---as its final parameter, and returns a Result.

Synopsis

Documentation

meta Source

Arguments

:: (FromJSON a, MonadIO m) 
=> RetrieveDoc

Parameters for the HEAD request

-> DocId

The ID of the design document

-> Maybe DocRev

A desired revision

-> Context 
-> m (Result a) 

Get the size and revision of the specified design document

The return value is an object that should only contain the keys "rev" and "size", that can be easily parsed into a pair of (DocRev, Int):

>>> (,) <$> (getKey "rev" >>= toOutputType) <*> (getKey "size" >>= toOutputType)

If the specified DocRev matches, returns a JSON Null, otherwise a JSON value for the document.

Status: Complete

get Source

Arguments

:: (FromJSON a, MonadIO m) 
=> RetrieveDoc

Parameters for the HEAD request

-> DocId

The ID of the design document

-> Maybe DocRev

A desired revision

-> Context 
-> m (Result a) 

Get the specified design document

The return value is an object whose fields often vary, so it is most easily decoded as a Value:

>>> value :: Result Value <- Design.get "pandas" Nothing ctx

If the specified DocRev matches, returns a JSON Null, otherwise a JSON value for the document.

Status: Complete

put Source

Arguments

:: (FromJSON a, MonadIO m, ToJSON b) 
=> ModifyDoc

Parameters for the request

-> DocId

The ID of the design document

-> Maybe DocRev

A desired revision

-> b 
-> Context 
-> m (Result a) 

Create or replace the specified design document

The return value is an object that can hold "id" and "rev" keys, but if you don't need those values, it is easily decoded into a Bool with our asBool combinator:

>>> value :: Result Bool <- Design.put modifyDoc "pandas" Nothing SomeValue ctx >>= asBool

Status: Complete

delete Source

Arguments

:: (FromJSON a, MonadIO m) 
=> ModifyDoc

Parameters for the request

-> DocId

The ID of the design document

-> Maybe DocRev

A desired revision

-> Context 
-> m (Result a) 

Delete the specified design document

The return value is an object that can hold "id" and "rev" keys, but if you don't need those values, it is easily decoded into a Bool with our asBool combinator:

>>> value :: Result Bool <- Design.delete modifyDoc "pandas" Nothing ctx >>= asBool

Status: Complete

copy Source

Arguments

:: (FromJSON a, MonadIO m) 
=> ModifyDoc

Parameters for the request

-> DocId

The ID of the design document

-> Maybe DocRev

A desired revision

-> DocId 
-> Context 
-> m (Result a) 

Copy the specified design document

The return value is an object that can hold "id" and "rev" keys, but if you don't need those values, it is easily decoded into a Bool with our asBool combinator:

>>> value :: Result Bool <- Design.delete modifyDoc "pandas" Nothing ctx >>= asBool

Status: Complete

info Source

Arguments

:: (FromJSON a, MonadIO m) 
=> DocId

The ID of the design document

-> Context 
-> m (Result a) 

Get information on a design document

The return value is an object whose fields often vary, so it is most easily decoded as a Value:

>>> value :: Result Value <- Design.info "pandas" ctx

Status: Complete

allDocs Source

Arguments

:: (FromJSON a, MonadIO m) 
=> ViewParams

Parameters for the request

-> DocId

The ID of the design document

-> DocId

The ID of the view

-> Context 
-> m (Result a) 

Get a list of all database documents

The return value is an object whose fields often vary, so it is most easily decoded as a Value:

>>> value :: Result Value <- Design.allDocs viewParams "pandas" "counter" ctx

Status: Complete

someDocs Source

Arguments

:: (FromJSON a, MonadIO m) 
=> ViewParams

Parameters for the request

-> DocId

The ID of the design document

-> DocId

The ID of the view

-> [DocId]

The IDs of the documents of interest

-> Context 
-> m (Result a) 

Get a list of some database documents

The return value is an object whose fields often vary, so it is most easily decoded as a Value:

>>> value :: Result Value <- Design.someDocs viewParams "pandas" "counter" ["a", "b"] ctx

Status: Complete

Internal combinators

viewBase :: ViewParams -> DocId -> DocId -> RequestBuilder () Source

Base bits for all view queries