persistent-mongoDB 2.1.2.2 → 2.1.4
raw patch · 3 files changed
+40/−11 lines, 3 filesdep +http-api-dataPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: http-api-data
API changes (from Hackage documentation)
- Database.Persist.MongoDB: instance Eq (BackendKey MongoContext)
- Database.Persist.MongoDB: instance Eq NoOrphanNominalDiffTime
- Database.Persist.MongoDB: instance Eq NoOrphanPortID
- Database.Persist.MongoDB: instance FromJSON (BackendKey MongoContext)
- Database.Persist.MongoDB: instance FromJSON MongoConf
- Database.Persist.MongoDB: instance FromJSON NoOrphanNominalDiffTime
- Database.Persist.MongoDB: instance FromJSON NoOrphanPortID
- Database.Persist.MongoDB: instance HasPersistBackend MongoContext MongoContext
- Database.Persist.MongoDB: instance MongoRegexSearchable Text
- Database.Persist.MongoDB: instance MongoRegexSearchable rs => MongoRegexSearchable (Maybe rs)
- Database.Persist.MongoDB: instance MongoRegexSearchable rs => MongoRegexSearchable [rs]
- Database.Persist.MongoDB: instance Num NoOrphanNominalDiffTime
- Database.Persist.MongoDB: instance Ord (BackendKey MongoContext)
- Database.Persist.MongoDB: instance PathPiece (BackendKey MongoContext)
- Database.Persist.MongoDB: instance PersistConfig MongoConf
- Database.Persist.MongoDB: instance PersistField (BackendKey MongoContext)
- Database.Persist.MongoDB: instance PersistField ObjectId
- Database.Persist.MongoDB: instance PersistFieldSql (BackendKey MongoContext)
- Database.Persist.MongoDB: instance PersistFieldSql ObjectId
- Database.Persist.MongoDB: instance PersistQuery MongoContext
- Database.Persist.MongoDB: instance PersistStore MongoContext
- Database.Persist.MongoDB: instance PersistUnique MongoContext
- Database.Persist.MongoDB: instance Read (BackendKey MongoContext)
- Database.Persist.MongoDB: instance Serialize ObjectId
- Database.Persist.MongoDB: instance Show (BackendKey MongoContext)
- Database.Persist.MongoDB: instance Show MongoAuth
- Database.Persist.MongoDB: instance Show MongoConf
- Database.Persist.MongoDB: instance Show MongoUpdateOperation
- Database.Persist.MongoDB: instance Show MongoUpdateOperator
- Database.Persist.MongoDB: instance Show MultiFilter
- Database.Persist.MongoDB: instance Show NoOrphanNominalDiffTime
- Database.Persist.MongoDB: instance Show NoOrphanPortID
- Database.Persist.MongoDB: instance Show ReplicaSetConfig
- Database.Persist.MongoDB: instance Show typ => Show (UpdateValueOp typ)
- Database.Persist.MongoDB: instance ToJSON (BackendKey MongoContext)
- Database.Persist.MongoDB: instance Val PersistValue
- Database.Persist.MongoDB: mgAccessMode :: MongoConf -> AccessMode
- Database.Persist.MongoDB: mgAuth :: MongoConf -> Maybe MongoAuth
- Database.Persist.MongoDB: mgConnectionIdleTime :: MongoConf -> NominalDiffTime
- Database.Persist.MongoDB: mgDatabase :: MongoConf -> Text
- Database.Persist.MongoDB: mgHost :: MongoConf -> Text
- Database.Persist.MongoDB: mgPoolStripes :: MongoConf -> Int
- Database.Persist.MongoDB: mgPort :: MongoConf -> PortID
- Database.Persist.MongoDB: mgReplicaSetConfig :: MongoConf -> Maybe ReplicaSetConfig
- Database.Persist.MongoDB: mgStripeConnections :: MongoConf -> Int
+ Database.Persist.MongoDB: [mgAccessMode] :: MongoConf -> AccessMode
+ Database.Persist.MongoDB: [mgAuth] :: MongoConf -> Maybe MongoAuth
+ Database.Persist.MongoDB: [mgConnectionIdleTime] :: MongoConf -> NominalDiffTime
+ Database.Persist.MongoDB: [mgDatabase] :: MongoConf -> Text
+ Database.Persist.MongoDB: [mgHost] :: MongoConf -> Text
+ Database.Persist.MongoDB: [mgPoolStripes] :: MongoConf -> Int
+ Database.Persist.MongoDB: [mgPort] :: MongoConf -> PortID
+ Database.Persist.MongoDB: [mgReplicaSetConfig] :: MongoConf -> Maybe ReplicaSetConfig
+ Database.Persist.MongoDB: [mgStripeConnections] :: MongoConf -> Int
+ Database.Persist.MongoDB: inList :: PersistField typ => EntityField v [typ] -> [typ] -> Filter v
+ Database.Persist.MongoDB: instance Data.Aeson.Types.Class.FromJSON (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance Data.Aeson.Types.Class.FromJSON Database.Persist.MongoDB.MongoConf
+ Database.Persist.MongoDB: instance Data.Aeson.Types.Class.FromJSON Database.Persist.MongoDB.NoOrphanNominalDiffTime
+ Database.Persist.MongoDB: instance Data.Aeson.Types.Class.FromJSON Database.Persist.MongoDB.NoOrphanPortID
+ Database.Persist.MongoDB: instance Data.Aeson.Types.Class.ToJSON (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance Data.Bson.Val Database.Persist.Types.Base.PersistValue
+ Database.Persist.MongoDB: instance Data.Serialize.Serialize Data.Bson.ObjectId
+ Database.Persist.MongoDB: instance Database.Persist.Class.PersistConfig.PersistConfig Database.Persist.MongoDB.MongoConf
+ Database.Persist.MongoDB: instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance Database.Persist.Class.PersistField.PersistField Data.Bson.ObjectId
+ Database.Persist.MongoDB: instance Database.Persist.Class.PersistQuery.PersistQuery Database.MongoDB.Query.MongoContext
+ Database.Persist.MongoDB: instance Database.Persist.Class.PersistStore.HasPersistBackend Database.MongoDB.Query.MongoContext Database.MongoDB.Query.MongoContext
+ Database.Persist.MongoDB: instance Database.Persist.Class.PersistStore.PersistStore Database.MongoDB.Query.MongoContext
+ Database.Persist.MongoDB: instance Database.Persist.Class.PersistUnique.PersistUnique Database.MongoDB.Query.MongoContext
+ Database.Persist.MongoDB: instance Database.Persist.MongoDB.MongoRegexSearchable Data.Text.Internal.Text
+ Database.Persist.MongoDB: instance Database.Persist.MongoDB.MongoRegexSearchable rs => Database.Persist.MongoDB.MongoRegexSearchable (GHC.Base.Maybe rs)
+ Database.Persist.MongoDB: instance Database.Persist.MongoDB.MongoRegexSearchable rs => Database.Persist.MongoDB.MongoRegexSearchable [rs]
+ Database.Persist.MongoDB: instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance Database.Persist.Sql.Class.PersistFieldSql Data.Bson.ObjectId
+ Database.Persist.MongoDB: instance GHC.Classes.Eq (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance GHC.Classes.Eq Database.Persist.MongoDB.NoOrphanNominalDiffTime
+ Database.Persist.MongoDB: instance GHC.Classes.Eq Database.Persist.MongoDB.NoOrphanPortID
+ Database.Persist.MongoDB: instance GHC.Classes.Ord (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance GHC.Num.Num Database.Persist.MongoDB.NoOrphanNominalDiffTime
+ Database.Persist.MongoDB: instance GHC.Read.Read (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance GHC.Show.Show (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance GHC.Show.Show Database.Persist.MongoDB.MongoAuth
+ Database.Persist.MongoDB: instance GHC.Show.Show Database.Persist.MongoDB.MongoConf
+ Database.Persist.MongoDB: instance GHC.Show.Show Database.Persist.MongoDB.MongoUpdateOperation
+ Database.Persist.MongoDB: instance GHC.Show.Show Database.Persist.MongoDB.MongoUpdateOperator
+ Database.Persist.MongoDB: instance GHC.Show.Show Database.Persist.MongoDB.MultiFilter
+ Database.Persist.MongoDB: instance GHC.Show.Show Database.Persist.MongoDB.NoOrphanNominalDiffTime
+ Database.Persist.MongoDB: instance GHC.Show.Show Database.Persist.MongoDB.NoOrphanPortID
+ Database.Persist.MongoDB: instance GHC.Show.Show Database.Persist.MongoDB.ReplicaSetConfig
+ Database.Persist.MongoDB: instance GHC.Show.Show typ => GHC.Show.Show (Database.Persist.MongoDB.UpdateValueOp typ)
+ Database.Persist.MongoDB: instance Web.HttpApiData.Internal.FromHttpApiData (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance Web.HttpApiData.Internal.ToHttpApiData (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext)
+ Database.Persist.MongoDB: ninList :: PersistField typ => EntityField v [typ] -> [typ] -> Filter v
- Database.Persist.MongoDB: docToEntityEither :: PersistEntity record => Document -> Either Text (Entity record)
+ Database.Persist.MongoDB: docToEntityEither :: (PersistEntity record) => Document -> Either Text (Entity record)
- Database.Persist.MongoDB: fieldName :: PersistEntity record => EntityField record typ -> Label
+ Database.Persist.MongoDB: fieldName :: (PersistEntity record) => EntityField record typ -> Label
- Database.Persist.MongoDB: oidToKey :: ToBackendKey MongoContext record => ObjectId -> Key record
+ Database.Persist.MongoDB: oidToKey :: (ToBackendKey MongoContext record) => ObjectId -> Key record
- Database.Persist.MongoDB: toUniquesDoc :: PersistEntity record => Unique record -> [Field]
+ Database.Persist.MongoDB: toUniquesDoc :: (PersistEntity record) => Unique record -> [Field]
Files
- ChangeLog.md +8/−0
- Database/Persist/MongoDB.hs +30/−10
- persistent-mongoDB.cabal +2/−1
ChangeLog.md view
@@ -1,3 +1,11 @@+## 2.1.4++* support http-api-data for url serialization++## 2.1.3++* Add list filtering functions `inList` and `ninList`+ ## 2.1.2 * Add `nestAnyEq` filter function
Database/Persist/MongoDB.hs view
@@ -43,6 +43,7 @@ -- $filters , nestEq, nestNe, nestGe, nestLe, nestIn, nestNotIn , anyEq, nestAnyEq, nestBsonEq, anyBsonEq, multiBsonEq+ , inList, ninList , (=~.) -- non-operator forms of filters , NestedField(..)@@ -121,7 +122,7 @@ import Data.Bson (ObjectId(..)) import qualified Database.MongoDB as DB import Database.MongoDB.Query (Database)-import Control.Applicative (Applicative)+import Control.Applicative (Applicative, (<$>)) import Network (PortID (PortNumber)) import Network.Socket (HostName) import Data.Maybe (mapMaybe, fromJust)@@ -130,7 +131,8 @@ import qualified Data.ByteString as BS import qualified Data.Text.Encoding as E import qualified Data.Serialize as Serialize-import Web.PathPieces (PathPiece (..))+import Web.PathPieces (PathPiece(..))+import Web.HttpApiData (ToHttpApiData(..), FromHttpApiData(..), parseUrlPieceMaybe, parseUrlPieceWithPrefix, readTextData) import Data.Conduit import Control.Monad.IO.Class (liftIO) import Data.Aeson (Value (Number), (.:), (.:?), (.!=), FromJSON(..), ToJSON(..), withText, withObject)@@ -152,6 +154,7 @@ import Control.Monad.Trans.Reader (ask, runReaderT) import Control.Monad.Trans.Control (MonadBaseControl) import Numeric (readHex)+import Unsafe.Coerce (unsafeCoerce) #if MIN_VERSION_base(4,6,0) import System.Environment (lookupEnv)@@ -210,15 +213,22 @@ data Connection = Connection DB.Pipe DB.Database type ConnectionPool = Pool.Pool Connection +instance ToHttpApiData (BackendKey DB.MongoContext) where+ toUrlPiece = keyToText++instance FromHttpApiData (BackendKey DB.MongoContext) where+ parseUrlPiece input = do+ s <- parseUrlPieceWithPrefix "o" input <!> return input+ MongoKey <$> readTextData s+ where+ infixl 3 <!>+ Left _ <!> y = y+ x <!> _ = x+ -- | ToPathPiece is used to convert a key to/from text instance PathPiece (BackendKey DB.MongoContext) where- toPathPiece = keyToText- fromPathPiece keyText = readMayMongoKey $- -- handle a JSON type prefix- -- 'o' is a non-hex character, so no confusion here- case T.uncons keyText of- Just ('o', prefixed) -> prefixed- _ -> keyText+ toPathPiece = toUrlPiece+ fromPathPiece = parseUrlPieceMaybe keyToText :: BackendKey DB.MongoContext -> Text keyToText = T.pack . show . unMongoKey@@ -1119,7 +1129,7 @@ deriving Show instance FromJSON MongoConf where- parseJSON v = modifyFailure ("Persistent: error loadomg MongoDB conf: " ++) $+ parseJSON v = modifyFailure ("Persistent: error loading MongoDB conf: " ++) $ flip (withObject "MongoConf") v $ \o ->do db <- o .: "database" host <- o .:? "host" .!= defaultHost@@ -1464,3 +1474,13 @@ ) => PersistUpdate -> NestedField record typ -> typ -> Update record nestedUpdateOp op nf v = BackendUpdate $ NestedUpdate nf $ UpdateValueOp (Left v) (Left op)++-- | Intersection of lists: if any value in the field is found in the list.+inList :: PersistField typ => EntityField v [typ] -> [typ] -> Filter v+f `inList` a = Filter (unsafeCoerce f) (Right a) In+infix 4 `inList`++-- | No intersection of lists: if no value in the field is found in the list.+ninList :: PersistField typ => EntityField v [typ] -> [typ] -> Filter v+f `ninList` a = Filter (unsafeCoerce f) (Right a) In+infix 4 `ninList`
persistent-mongoDB.cabal view
@@ -1,5 +1,5 @@ name: persistent-mongoDB-version: 2.1.2.2+version: 2.1.4 license: MIT license-file: LICENSE author: Greg Weber <greg@gregweber.info>@@ -32,6 +32,7 @@ , network >= 2.2.1.7 , cereal >= 0.3.0.0 , path-pieces >= 0.1+ , http-api-data >= 0.2 && < 0.3 , monad-control >= 0.3 , aeson >= 0.6.2 , attoparsec