BSON.lookup
This commit is contained in:
parent
ee8cd25138
commit
cef52ebf12
1 changed files with 8 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue