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(..), BsonDoc(..),
toBsonDoc, toBsonDoc,
BinarySubType(..), BinarySubType(..),
-- * BsonDoc Operations
lookup,
-- * Conversion -- * Conversion
fromBson, toBson fromBson, toBson
) )
where where
import Prelude hiding (lookup)
import Control.Monad import Control.Monad
import Data.Binary import Data.Binary
import Data.Binary.Get import Data.Binary.Get
@ -88,6 +92,10 @@ newtype BsonDoc = BsonDoc {
toBsonDoc :: [(L8.ByteString, BsonValue)] -> BsonDoc toBsonDoc :: [(L8.ByteString, BsonValue)] -> BsonDoc
toBsonDoc = BsonDoc . Map.fromList 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 DataType =
Data_min_key | -- -1 Data_min_key | -- -1
Data_number | -- 1 Data_number | -- 1