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.Response

Description

Calls to CouchDB can return values that have well-defined structure beyond their simple JSON content, but that don't necessarily warrant full-blown data types with FromJSON instances and the like. We want to provide convenient conversions when that is the case.

result <- Database.compact cxt `ap` asBool
if result
  then ...
  else ...

Synopsis

Documentation

asAnything :: FromJSON a => Result Value -> Result a Source

Attempt to decode the value into anything with a FromJSON constraint.

This is really about translating Result values into our Result values.

asBool :: Result Value -> Result Bool Source

Attempt to construct a Bool value.

This assumes the routine conforms to CouchDB's {"ok": true} return convention.

asUUID :: Result Value -> Result [UUID] Source

Attempt to construct a list of UUID values.

CouchDB returns uuids as string values in a form that Data.UUID cannot consume directly, so we provide this standard conversion.

getKey :: FromJSON a => Text -> Result Value -> Result a Source

Attempt to extract the value of a particular key.