From f173d9d0a7b946008fcccdefb7ef6fb5173a6a05 Mon Sep 17 00:00:00 2001 From: "Scott R. Parish" Date: Tue, 19 Jan 2010 20:30:04 -0600 Subject: [PATCH] convertible for BsonObject --- Database/MongoDB/BSON.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Database/MongoDB/BSON.hs b/Database/MongoDB/BSON.hs index d7907d5..f6460b1 100644 --- a/Database/MongoDB/BSON.hs +++ b/Database/MongoDB/BSON.hs @@ -409,6 +409,21 @@ instance Convertible BsonValue S8.ByteString where safeConvert (BsonString bs) = return $ C8.concat $ L.toChunks bs safeConvert v = unsupportedError v +instance Convertible BsonDoc BsonValue where + safeConvert = return . BsonObject + +instance Convertible [(String, BsonValue)] BsonValue where + safeConvert = return . BsonObject . toBsonDoc + +instance Convertible [(L8.ByteString, BsonValue)] BsonValue where + safeConvert = return . BsonObject . toBsonDoc + +instance Convertible (Map.Map String BsonValue) BsonValue where + safeConvert = return . BsonObject . BsonDoc . Map.mapKeys L8.fromString + +instance Convertible (Map.Map L8.ByteString BsonValue) BsonValue where + safeConvert = return . BsonObject . BsonDoc + instance Convertible BsonValue [Double] where safeConvert (BsonArray a) = mapM safeConvert a safeConvert v = unsupportedError v