CouchDB-0.8.0.1: CouchDB interfaceSource codeContentsIndex
Database.CouchDB
Contents
Initialization
Databases
Documents
Views
Description
Interface to CouchDB.
Synopsis
data CouchMonad a
runCouchDB :: String -> Int -> CouchMonad a -> IO a
runCouchDB' :: CouchMonad a -> IO a
createDB :: String -> CouchMonad ()
dropDB :: String -> CouchMonad Bool
newNamedDoc :: JSON a => String -> String -> a -> CouchMonad (Either String String)
newDoc :: JSON a => String -> a -> CouchMonad (JSString, JSString)
updateDoc :: JSON a => String -> (JSString, JSString) -> a -> CouchMonad (Maybe (JSString, JSString))
deleteDoc :: String -> (JSString, JSString) -> CouchMonad Bool
getDoc :: JSON a => String -> String -> CouchMonad (Maybe (JSString, JSString, a))
getAndUpdateDoc :: JSON a => String -> String -> (a -> a) -> CouchMonad (Maybe String)
getAllDocIds :: String -> CouchMonad [String]
data CouchView
= ViewMap String String
| ViewMapReduce String String String
newView :: String -> String -> [CouchView] -> CouchMonad ()
queryView :: JSON a => String -> String -> String -> [(String, JSValue)] -> CouchMonad [(JSString, a)]
queryViewKeys :: String -> String -> String -> [(String, JSValue)] -> CouchMonad [String]
Initialization
data CouchMonad a Source
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.
show/hide Instances
runCouchDBSource
::
=> Stringhostname
-> Intport
-> CouchMonad a
-> IO a
runCouchDB' :: CouchMonad a -> IO aSource
Connects to the CouchDB server at localhost:5984.
Databases
createDB :: String -> CouchMonad ()Source
Creates a new database. Throws an exception if the database already exists.
dropDBSource
:: String
-> CouchMonad BoolFalse if the database does not exist
Documents
newNamedDocSource
:: JSON a
=> Stringdatabase name
-> Stringdocument name
-> adocument body
-> CouchMonad (Either String String)Returns Left on a conflict. Returns Right with the revision number on success.
newDocSource
:: JSON a
=> Stringdatabase name
-> adocument body
-> CouchMonad (JSString, JSString)id and rev of new document
updateDocSource
:: JSON a
=> Stringdatabase
-> (JSString, JSString)document and revision
-> anew value
-> CouchMonad (Maybe (JSString, JSString))
deleteDocSource
:: Stringdatabase
-> (JSString, JSString)document and revision
-> CouchMonad Bool
getDocSource
:: JSON a
=> Stringdatabase name
-> Stringdocument name
-> CouchMonad (Maybe (JSString, JSString, a))Nothing if the doc does not exist
getAndUpdateDocSource
:: JSON a
=> Stringdatabase
-> Stringdocument name
-> a -> aupdate function
-> CouchMonad (Maybe String)If the update succeeds, return the revision number of the result.
getAllDocIdsSource
:: Stringdatabase name
-> CouchMonad [String]
Views
Creating and querying views
data CouchView Source
Constructors
ViewMap String String
ViewMapReduce String String String
newViewSource
:: Stringdatabase name
-> Stringview set name
-> [CouchView]views
-> CouchMonad ()
queryViewSource
:: JSON a
=> Stringdatabase
-> Stringdesign
-> Stringview
-> [(String, JSValue)]query parameters |Returns a list of rows. Each row is a key, value pair.
-> CouchMonad [(JSString, a)]
queryViewKeysSource
:: Stringdatabase
-> Stringdesign
-> Stringview
-> [(String, JSValue)]query parameters
-> CouchMonad [String]
Like queryView, but only returns the keys. Use this for key-only views where the value is completely ignored.
Produced by Haddock version 2.3.0