Permalink
Browse files

collect ids from insert lazily in case not used

  • Loading branch information...
1 parent 35801ef commit 4307fea5aa7bf2164a48f14770e6ae7054d61a62 Tony Hannan committed Aug 18, 2011
Showing with 3 additions and 3 deletions.
  1. +2 −2 Database/MongoDB/Query.hs
  2. +1 −1 mongoDB.cabal
@@ -40,7 +40,7 @@ module Database.MongoDB.Query (
import Prelude as X hiding (lookup)
import Data.UString as U (UString, dropWhile, any, tail)
-import Data.Bson (Document, at, lookup, look, Field(..), (=:), (=?), Label, Value(String,Doc), Javascript, genObjectId)
+import Data.Bson (Document, at, valueAt, lookup, look, Field(..), (=:), (=?), Label, Value(String,Doc), Javascript, genObjectId)
import Database.MongoDB.Internal.Protocol (Pipe, Notice(..), Request(GetMore), Reply(..), QueryOption(..), ResponseFlag(..), InsertOption(..), UpdateOption(..), DeleteOption(..), CursorId, FullCollection, Username, Password, pwKey)
import qualified Database.MongoDB.Internal.Protocol as P (send, call, Request(Query))
import Database.MongoDB.Internal.Util (MonadIO', loop, liftIOE, true1, (<.>))
@@ -274,7 +274,7 @@ insert' opts col docs = do
db <- thisDatabase
docs' <- liftIO $ mapM assignId docs
write (Insert (db <.> col) opts docs')
- mapM (look "_id") docs'
+ return $ map (valueAt "_id") docs'
assignId :: Document -> IO Document
-- ^ Assign a unique value to _id field if missing
View
@@ -1,5 +1,5 @@
name: mongoDB
-version: 1.0.1
+version: 1.0.2
build-type: Simple
license: OtherLicense
license-file: LICENSE

0 comments on commit 4307fea

Please sign in to comment.