BSON.lookup

This commit is contained in:
Scott R. Parish 2010-01-18 15:03:25 -06:00
parent ee8cd25138
commit cef52ebf12

View file

@ -30,10 +30,14 @@ module Database.MongoDB.BSON
BsonDoc(..),
toBsonDoc,
BinarySubType(..),
-- * BsonDoc Operations
lookup,
-- * Conversion
fromBson, toBson
)
where
import Prelude hiding (lookup)
import Control.Monad
import Data.Binary
import Data.Binary.Get
@ -88,6 +92,10 @@ newtype BsonDoc = BsonDoc {
toBsonDoc :: [(L8.ByteString, BsonValue)] -> BsonDoc
toBsonDoc = BsonDoc . Map.fromList
-- | Return the BsonValue for given key, if any.
lookup :: L8.ByteString -> BsonDoc -> Maybe BsonValue
lookup k = Map.lookup k . fromBsonDoc
data DataType =
Data_min_key | -- -1
Data_number | -- 1