findOne
This commit is contained in:
parent
378bc42393
commit
121dcbfd93
1 changed files with 11 additions and 3 deletions
|
@ -36,9 +36,9 @@ module Database.MongoDB
|
||||||
QueryOpt(..),
|
QueryOpt(..),
|
||||||
UpdateFlag(..),
|
UpdateFlag(..),
|
||||||
delete, insert, insertMany, query, remove, update,
|
delete, insert, insertMany, query, remove, update,
|
||||||
-- * Convience database operations
|
-- * Convience collection operations
|
||||||
find, quickFind, quickFind',
|
find, findOne, quickFind, quickFind',
|
||||||
-- * Cursor operations
|
-- * Cursor
|
||||||
Cursor,
|
Cursor,
|
||||||
allDocs, allDocs', finish, nextDoc,
|
allDocs, allDocs', finish, nextDoc,
|
||||||
)
|
)
|
||||||
|
@ -259,6 +259,14 @@ insertMany c col docs = do
|
||||||
find :: Connection -> Collection -> Selector -> IO Cursor
|
find :: Connection -> Collection -> Selector -> IO Cursor
|
||||||
find c col sel = query c col [] 0 0 sel []
|
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
|
-- | Perform a query and return the result as a lazy list. Be sure to
|
||||||
-- understand the comments about using the lazy list given for
|
-- understand the comments about using the lazy list given for
|
||||||
-- 'allDocs'.
|
-- 'allDocs'.
|
||||||
|
|
Loading…
Reference in a new issue