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,
|
||||
delete, insert, insertMany, query, remove, update,
|
||||
find,
|
||||
allDocs, finish, nextDoc,
|
||||
allDocs, allDocs', finish, nextDoc,
|
||||
Collection, FieldSelector, NumToSkip, NumToReturn, RequestID, Selector,
|
||||
Opcode(..),
|
||||
QueryOpt(..),
|
||||
|
@ -298,6 +298,16 @@ allDocs cur = unsafeInterleaveIO $ do
|
|||
Nothing -> return []
|
||||
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
|
||||
doc <- get
|
||||
docBytes' <- getRemainingLazyByteString
|
||||
|
|
Loading…
Reference in a new issue