This commit is contained in:
Scott R. Parish 2010-01-18 17:31:41 -06:00
parent 378bc42393
commit 121dcbfd93

View file

@ -36,9 +36,9 @@ module Database.MongoDB
QueryOpt(..),
UpdateFlag(..),
delete, insert, insertMany, query, remove, update,
-- * Convience database operations
find, quickFind, quickFind',
-- * Cursor operations
-- * Convience collection operations
find, findOne, quickFind, quickFind',
-- * Cursor
Cursor,
allDocs, allDocs', finish, nextDoc,
)
@ -259,6 +259,14 @@ insertMany c col docs = do
find :: Connection -> Collection -> Selector -> IO Cursor
find c col sel = query c col [] 0 0 sel []
-- | Query, but only return the first result, if any.
findOne :: Connection -> Collection -> Selector -> IO (Maybe BsonDoc)
findOne c col sel = do
cur <- find c col sel
el <- nextDoc cur
finish cur
return el
-- | Perform a query and return the result as a lazy list. Be sure to
-- understand the comments about using the lazy list given for
-- 'allDocs'.