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(..),
|
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
|
||||||
|
|
Loading…
Reference in a new issue