packages feed

persistent-mongoDB 2.1.1 → 2.1.2

raw patch · 3 files changed

+36/−23 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Database.Persist.MongoDB: instance FromJSON MongoConf
+ Database.Persist.MongoDB: nestAnyEq :: (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record [typ] -> typ -> Filter record

Files

+ ChangeLog.md view
@@ -0,0 +1,4 @@+## 2.1.2++* Add `nestAnyEq` filter function+* Add `FromJSON` instance for `MongoConf`
Database/Persist/MongoDB.hs view
@@ -42,7 +42,7 @@     -- ** Filters     -- $filters     , nestEq, nestNe, nestGe, nestLe, nestIn, nestNotIn-    , anyEq, nestBsonEq, anyBsonEq, multiBsonEq+    , anyEq, nestAnyEq, nestBsonEq, anyBsonEq, multiBsonEq     , (=~.)     -- non-operator forms of filters     , NestedField(..)@@ -133,8 +133,8 @@ import Web.PathPieces (PathPiece (..)) import Data.Conduit import Control.Monad.IO.Class (liftIO)-import Data.Aeson (Value (Object, Number), (.:), (.:?), (.!=), FromJSON(..), ToJSON(..), withText)-import Control.Monad (mzero, liftM, (>=>), forM_)+import Data.Aeson (Value (Number), (.:), (.:?), (.!=), FromJSON(..), ToJSON(..), withText, withObject)+import Control.Monad (liftM, (>=>), forM_) import qualified Data.Conduit.Pool as Pool import Data.Time (NominalDiffTime) #ifdef HIGH_PRECISION_DATE@@ -861,6 +861,7 @@ mongoFilterToDoc :: PersistEntity record => MongoFilter record -> DB.Document mongoFilterToDoc (NestedFilter   field op) = mongoFilterToBSON (nestedFieldName field) op mongoFilterToDoc (ArrayFilter field op) = mongoFilterToBSON (fieldName field) op+mongoFilterToDoc (NestedArrayFilter field op) = mongoFilterToBSON (nestedFieldName field) op mongoFilterToDoc (RegExpFilter fn (reg, opts)) = [ fieldName fn  DB.:= DB.RegEx (DB.Regex reg opts)]  nestedFieldName :: forall record typ. PersistEntity record => NestedField record typ -> Text@@ -1116,15 +1117,8 @@ data ReplicaSetConfig = ReplicaSetConfig DB.ReplicaSetName [DB.Host]     deriving Show --instance PersistConfig MongoConf where-    type PersistConfigBackend MongoConf = DB.Action-    type PersistConfigPool MongoConf = ConnectionPool--    createPoolConfig = createMongoPool--    runPool c = runMongoDBPool (mgAccessMode c)-    loadConfig (Object o) = do+instance FromJSON MongoConf where+    parseJSON = withObject "MongoConf" $ \o ->do         db                  <- o .:  "database"         host                <- o .:? "host" .!= defaultHost         NoOrphanPortID port <- o .:? "port" .!= NoOrphanPortID DB.defaultPort@@ -1169,16 +1163,16 @@           }       where         confirmWrites = "ConfirmWrites"-    {--        safeRead :: String -> T.Text -> MEither String Int-        safeRead name t = case reads s of-            (i, _):_ -> MRight i-            []       -> MLeft $ concat ["Invalid value for ", name, ": ", s]-          where-            s = T.unpack t-            -}-    loadConfig _ = mzero +instance PersistConfig MongoConf where+    type PersistConfigBackend MongoConf = DB.Action+    type PersistConfigPool MongoConf = ConnectionPool++    createPoolConfig = createMongoPool++    runPool c = runMongoDBPool (mgAccessMode c)+    loadConfig = parseJSON+ -- | docker integration: change the host to the mongodb link applyDockerEnv :: MongoConf -> IO MongoConf applyDockerEnv mconf = do@@ -1260,6 +1254,10 @@           ArrayFilter             (EntityField record [typ])             (MongoFilterOperator typ)+      | forall typ. PersistField typ =>+          NestedArrayFilter+            (NestedField record [typ])+            (MongoFilterOperator typ)       | forall typ. MongoRegexSearchable typ =>           RegExpFilter             (EntityField record typ)@@ -1323,6 +1321,7 @@ infixr 4 `nestNotIn`  infixr 4 `anyEq`+infixr 4 `nestAnyEq` infixr 4 `nestBsonEq` infixr 4 `multiBsonEq` infixr 4 `anyBsonEq`@@ -1366,7 +1365,7 @@ nf `nestBsonEq` val = BackendFilter $     NestedFilter nf $ MongoFilterOperator val --- | Like nestEq, but for an embedded list.+-- | Like '(==.)' but for an embedded list. -- Checks to see if the list contains an item. -- -- In Haskell we need different equality functions for embedded fields that are lists or non-lists to keep things type-safe.@@ -1380,6 +1379,15 @@         ) => EntityField record [typ] -> typ -> Filter record fld `anyEq` val = BackendFilter $     ArrayFilter fld $ PersistFilterOperator (Left val) Eq++-- | Like nestEq, but for an embedded list.+-- Checks to see if the nested list contains an item.+nestAnyEq :: forall record typ.+        ( PersistField typ+        , PersistEntityBackend record ~ DB.MongoContext+        ) => NestedField record [typ] -> typ -> Filter record+fld `nestAnyEq` val = BackendFilter $+    NestedArrayFilter fld $ PersistFilterOperator (Left val) Eq  multiBsonEq :: forall record typ.         ( PersistField typ
persistent-mongoDB.cabal view
@@ -1,5 +1,5 @@ name:            persistent-mongoDB-version:         2.1.1+version:         2.1.2 license:         MIT license-file:    LICENSE author:          Greg Weber <greg@gregweber.info>@@ -12,6 +12,7 @@ homepage:        http://www.yesodweb.com/book/persistent bug-reports:     https://github.com/yesodweb/persistent/issues description:     MongoDB backend for the persistent library.+extra-source-files: ChangeLog.md  Flag high_precision_date    Description: for MongoDB use a time storage with nano second precision.