-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | CouchDB interface -- -- CouchDB interface @package CouchDB @version 1.2 -- | Convenient functions for parsing JSON responses. Use these functions -- to write the readJSON method of the JSON class. module Database.CouchDB.JSON jsonString :: JSValue -> Result String jsonInt :: Integral n => JSValue -> Result n jsonObject :: JSValue -> Result [(String, JSValue)] -- | Extract a field as a value of type a. If the field does not -- exist or cannot be parsed as type a, fail. jsonField :: JSON a => String -> [(String, JSValue)] -> Result a jsonBool :: JSValue -> Result Bool -- | True when the field is defined and is true. Otherwise, -- False. jsonIsTrue :: String -> [(String, JSValue)] -> Result Bool -- | Interface to CouchDB. module Database.CouchDB -- | A computation that interacts with a CouchDB database. This monad -- encapsulates the IO monad, a persistent HTTP connnection to a -- CouchDB database and enough information to re-open the connection if -- it is closed. data CouchMonad a runCouchDB :: String -> Int -> CouchMonad a -> IO a -- | Connects to the CouchDB server at localhost:5984. runCouchDB' :: CouchMonad a -> IO a runCouchDBURI :: URI -> CouchMonad a -> IO a -- | Describes a connection to a CouchDB database. This type is -- encapsulated by CouchMonad. data CouchConn -- | Run a CouchDB computation with an existing CouchDB connection. runCouchDBWith :: CouchConn -> CouchMonad a -> IO a -- | Create a CouchDB connection for use with runCouchDBWith. createCouchConn :: String -> Int -> IO (CouchConn) -- | Create a CouchDB from an URI connection for use with runCouchDBWith. createCouchConnFromURI :: URI -> IO (CouchConn) -- | Closes an open CouchDB connection closeCouchConn :: CouchConn -> IO () -- | Database name data DB -- | Returns a safe database name. Signals an error if the name is invalid. db :: String -> DB isDBString :: String -> Bool -- | Creates a new database. Throws an exception if the database already -- exists. createDB :: String -> CouchMonad () dropDB :: String -> CouchMonad Bool getAllDBs :: CouchMonad [DB] -- | Document name data Doc -- | Document revision number. data Rev -- | Returns a safe document name. Signals an error if the name is invalid. doc :: String -> Doc -- | Returns a Rev rev :: String -> Rev isDocString :: String -> Bool newNamedDoc :: JSON a => DB -> Doc -> a -> CouchMonad (Either String Rev) newDoc :: JSON a => DB -> a -> CouchMonad (Doc, Rev) updateDoc :: JSON a => DB -> (Doc, Rev) -> a -> CouchMonad (Maybe (Doc, Rev)) bulkUpdateDocs :: JSON a => DB -> [a] -> CouchMonad (Maybe [Either String (Doc, Rev)]) deleteDoc :: DB -> (Doc, Rev) -> CouchMonad Bool -- | Delete a doc by document identifier (revision number not needed). This -- operation first retreives the document to get its revision number. It -- fails if the document doesn't exist or there is a conflict. forceDeleteDoc :: DB -> Doc -> CouchMonad Bool -- | Gets a document as a raw JSON value. Returns the document id, revision -- and value as a JSObject. These fields are queried lazily, and -- may fail later if the response from the server is malformed. getDocPrim :: DB -> Doc -> CouchMonad (Maybe (Doc, Rev, [(String, JSValue)])) getDocRaw :: DB -> Doc -> CouchMonad (Maybe String) getDoc :: JSON a => DB -> Doc -> CouchMonad (Maybe (Doc, Rev, a)) getAllDocs :: JSON a => DB -> [(String, JSValue)] -> CouchMonad [(Doc, a)] getAndUpdateDoc :: JSON a => DB -> Doc -> (a -> IO a) -> CouchMonad (Maybe Rev) getAllDocIds :: DB -> CouchMonad [Doc] data CouchView ViewMap :: String -> String -> CouchView ViewMapReduce :: String -> String -> String -> CouchView newView :: String -> String -> [CouchView] -> CouchMonad () queryView :: JSON a => DB -> Doc -> Doc -> [(String, JSValue)] -> CouchMonad [(Doc, a)] -- | Like queryView, but only returns the keys. Use this for -- key-only views where the value is completely ignored. queryViewKeys :: DB -> Doc -> Doc -> [(String, JSValue)] -> CouchMonad [Doc] instance Eq Rev instance Ord Rev instance Eq Doc instance Ord Doc instance Read Doc instance JSON Doc instance Show Doc instance Show Rev instance JSON DB instance Show DB