Copyright | Copyright (c) 2015, Michael Alan Dorman |
---|---|
License | MIT |
Maintainer | mdorman@jaunder.io |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
This module is not intended to be used directly---it is used to construct a number of otherwise-similar modules, where the modules are primarily concerned with the existence (or not) of a path prefix for documents.
The functions here are effectively derived from (and presented in the same order as) the Document API documentation, though we don't link back to the specific functions here, since they're not meant for direct use.
Each function takes a Context
---which, among other things, holds the name of the database---as its final parameter, and returns a Result
.
- meta :: (FromJSON a, MonadIO m) => ByteString -> RetrieveDoc -> DocId -> Maybe DocRev -> Context -> m (Result a)
- get :: (FromJSON a, MonadIO m) => ByteString -> RetrieveDoc -> DocId -> Maybe DocRev -> Context -> m (Result a)
- put :: (FromJSON a, MonadIO m, ToJSON b) => ByteString -> ModifyDoc -> DocId -> Maybe DocRev -> b -> Context -> m (Result a)
- delete :: (FromJSON a, MonadIO m) => ByteString -> ModifyDoc -> DocId -> Maybe DocRev -> Context -> m (Result a)
- copy :: (FromJSON a, MonadIO m) => ByteString -> ModifyDoc -> DocId -> Maybe DocRev -> DocId -> Context -> m (Result a)
- docPath :: ByteString -> DocId -> RequestBuilder ()
- accessBase :: ByteString -> DocId -> Maybe DocRev -> RequestBuilder ()
- modBase :: ByteString -> ModifyDoc -> DocId -> Maybe DocRev -> RequestBuilder ()
Documentation
:: (FromJSON a, MonadIO m) | |
=> ByteString | The prefix to use for the document |
-> RetrieveDoc | Parameters for document retrieval |
-> DocId | The document ID |
-> Maybe DocRev | An optional document revision |
-> Context | |
-> m (Result a) |
Get the size and revision of the specified 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
:: (FromJSON a, MonadIO m) | |
=> ByteString | A prefix for the document ID |
-> RetrieveDoc | Parameters for document retrieval |
-> DocId | The document ID |
-> Maybe DocRev | An optional document revision |
-> Context | |
-> m (Result a) |
Get the specified document
The return value is an object whose fields often vary, so it is most easily decoded as a Value
:
>>>
value :: Result Value <- DocBase.get "prefix" "pandas" Nothing ctx
If the specified DocRev matches, returns a JSON Null, otherwise a JSON value for the document.
Status: Complete
:: (FromJSON a, MonadIO m, ToJSON b) | |
=> ByteString | A prefix for the document ID |
-> ModifyDoc | The parameters for modifying the document |
-> DocId | The document ID |
-> Maybe DocRev | An optional document revision |
-> b | The document |
-> Context | |
-> m (Result a) |
Create or replace the specified 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 <- DocBase.put "prefix" modifyDoc "pandas" Nothing SomeValue ctx >>= asBool
Status: Complete
:: (FromJSON a, MonadIO m) | |
=> ByteString | A prefix for the document ID |
-> ModifyDoc | The parameters for modifying the document |
-> DocId | The document ID |
-> Maybe DocRev | An optional document revision |
-> Context | |
-> m (Result a) |
Delete the specified 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 <- DocBase.delete "prefix" modifyDoc "pandas" Nothing ctx >>= asBool
Status: Complete
:: (FromJSON a, MonadIO m) | |
=> ByteString | A prefix for the document ID |
-> ModifyDoc | The parameters for modifying the document |
-> DocId | The document ID |
-> Maybe DocRev | An optional document revision |
-> DocId | The destination document ID |
-> Context | |
-> m (Result a) |
Copy the specified 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 <- DocBase.delete "prefix" modifyDoc "pandas" Nothing ctx >>= asBool
Status: Complete
Internal combinators
:: ByteString | A prefix for the document ID |
-> DocId | The document ID |
-> RequestBuilder () |
Construct a path in a consistent fashion
:: ByteString | A prefix for the document ID |
-> DocId | The document ID |
-> Maybe DocRev | An optional document revision |
-> RequestBuilder () |
All retrievals want to allow 304s
:: ByteString | A prefix for the document ID |
-> ModifyDoc | The parameters for modifying the document |
-> DocId | The document ID |
-> Maybe DocRev | An optional document revision |
-> RequestBuilder () |
All modifications want to allow conflict recognition and parameters