allDocs': a strict version of allDocs
This commit is contained in:
parent
4c17f8e646
commit
183e619362
1 changed files with 11 additions and 1 deletions
|
@ -28,7 +28,7 @@ module Database.MongoDB
|
||||||
connect, connectOnPort, conClose,
|
connect, connectOnPort, conClose,
|
||||||
delete, insert, insertMany, query, remove, update,
|
delete, insert, insertMany, query, remove, update,
|
||||||
find,
|
find,
|
||||||
allDocs, finish, nextDoc,
|
allDocs, allDocs', finish, nextDoc,
|
||||||
Collection, FieldSelector, NumToSkip, NumToReturn, RequestID, Selector,
|
Collection, FieldSelector, NumToSkip, NumToReturn, RequestID, Selector,
|
||||||
Opcode(..),
|
Opcode(..),
|
||||||
QueryOpt(..),
|
QueryOpt(..),
|
||||||
|
@ -298,6 +298,16 @@ allDocs cur = unsafeInterleaveIO $ do
|
||||||
Nothing -> return []
|
Nothing -> return []
|
||||||
Just d -> allDocs cur >>= return . (d :)
|
Just d -> allDocs cur >>= return . (d :)
|
||||||
|
|
||||||
|
{- | Returns a strict list of all (of the rest) of the documents in
|
||||||
|
the cursor. This means that all of the documents will immediately be
|
||||||
|
read out of the database and loaded into memory. -}
|
||||||
|
allDocs' :: Cursor -> IO [BSONObject]
|
||||||
|
allDocs' cur = do
|
||||||
|
doc <- nextDoc cur
|
||||||
|
case doc of
|
||||||
|
Nothing -> return []
|
||||||
|
Just d -> allDocs' cur >>= return . (d :)
|
||||||
|
|
||||||
getFirstDoc docBytes = flip runGet docBytes $ do
|
getFirstDoc docBytes = flip runGet docBytes $ do
|
||||||
doc <- get
|
doc <- get
|
||||||
docBytes' <- getRemainingLazyByteString
|
docBytes' <- getRemainingLazyByteString
|
||||||
|
|
Loading…
Reference in a new issue