-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Backend for the persistent library using mongoDB. -- -- MongoDB backend for the persistent library. @package persistent-mongoDB @version 2.9.0 -- | Use persistent-mongodb the same way you would use other persistent -- libraries and refer to the general persistent documentation. There are -- some new MongoDB specific filters under the filters section. These -- help extend your query into a nested document. -- -- However, at some point you will find the normal Persistent APIs -- lacking. and want lower level-level MongoDB access. There are -- functions available to make working with the raw driver easier: they -- are under the Entity conversion section. You should still use the same -- connection pool that you are using for Persistent. -- -- MongoDB is a schema-less database. The MongoDB Persistent backend does -- not help perform migrations. Unlike SQL backends, uniqueness -- constraints cannot be created for you. You must place a unique index -- on unique fields. module Database.Persist.MongoDB collectionName :: (PersistEntity record, PersistEntityBackend record ~ MongoContext) => record -> Text docToEntityEither :: forall record. PersistEntity record => Document -> Either Text (Entity record) docToEntityThrow :: forall m record. (MonadIO m, PersistEntity record, PersistEntityBackend record ~ MongoContext) => Document -> m (Entity record) -- | convert a PersistEntity into document fields. unlike -- toInsertDoc, nulls are included. recordToDocument :: (PersistEntity record, PersistEntityBackend record ~ MongoContext) => record -> Document documentFromEntity :: (PersistEntity record, PersistEntityBackend record ~ MongoContext) => Entity record -> Document -- | convert a PersistEntity into document fields. for inserts only: nulls -- are ignored so they will be unset in the document. -- recordToDocument includes nulls toInsertDoc :: forall record. (PersistEntity record, PersistEntityBackend record ~ MongoContext) => record -> Document entityToInsertDoc :: forall record. (PersistEntity record, PersistEntityBackend record ~ MongoContext) => Entity record -> Document updatesToDoc :: (PersistEntity record, PersistEntityBackend record ~ MongoContext) => [Update record] -> Document filtersToDoc :: (PersistEntity record, PersistEntityBackend record ~ MongoContext) => [Filter record] -> Document -- | convert a unique key into a MongoDB document toUniquesDoc :: forall record. PersistEntity record => Unique record -> [Field] -- | Point to an array field with an embedded object and give a deeper -- query into the embedded object. Use with nestEq. (->.) :: forall record emb typ. PersistEntity emb => EntityField record [emb] -> EntityField emb typ -> NestedField record typ infixr 6 ->. -- | Point to an array field with an embedded object and give a deeper -- query into the embedded object. This level of nesting is not the final -- level. Use ->. or &->. to point to the final -- level. (~>.) :: forall record typ emb. PersistEntity emb => EntityField record [emb] -> NestedField emb typ -> NestedField record typ infixr 5 ~>. -- | Same as &->., but Works against a Maybe type (?&->.) :: forall record typ nest. PersistEntity nest => EntityField record (Maybe nest) -> EntityField nest typ -> NestedField record typ infixr 6 ?&->. -- | Same as &~>., but works against a Maybe type (?&~>.) :: forall val nes nes1. PersistEntity nes1 => EntityField val (Maybe nes1) -> NestedField nes1 nes -> NestedField val nes infixr 5 ?&~>. -- | Point to a nested field to query. This field is not an array type. Use -- with nestEq. (&->.) :: forall record typ nest. PersistEntity nest => EntityField record nest -> EntityField nest typ -> NestedField record typ infixr 6 &->. -- | Point to a nested field to query. This field is not an array type. -- This level of nesting is not the final level. Use ->. or -- &>. to point to the final level. (&~>.) :: forall val nes nes1. PersistEntity nes1 => EntityField val nes1 -> NestedField nes1 nes -> NestedField val nes infixr 5 &~>. -- | The normal Persistent equality test ==. is not generic enough. -- Instead use this with the drill-down arrow operaters such as -- ->. -- -- using this as the only query filter is similar to the following in the -- mongoDB shell -- --
-- db.Collection.find({"object.field": item})
--
nestEq :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Filter record
infixr 4 `nestEq`
-- | The normal Persistent equality test ==. is not generic enough.
-- Instead use this with the drill-down arrow operaters such as
-- ->.
--
-- using this as the only query filter is similar to the following in the
-- mongoDB shell
--
--
-- db.Collection.find({"object.field": item})
--
nestNe :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Filter record
infixr 4 `nestNe`
-- | The normal Persistent equality test ==. is not generic enough.
-- Instead use this with the drill-down arrow operaters such as
-- ->.
--
-- using this as the only query filter is similar to the following in the
-- mongoDB shell
--
--
-- db.Collection.find({"object.field": item})
--
nestGe :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Filter record
infixr 4 `nestGe`
-- | The normal Persistent equality test ==. is not generic enough.
-- Instead use this with the drill-down arrow operaters such as
-- ->.
--
-- using this as the only query filter is similar to the following in the
-- mongoDB shell
--
--
-- db.Collection.find({"object.field": item})
--
nestLe :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Filter record
infixr 4 `nestLe`
-- | The normal Persistent equality test ==. is not generic enough.
-- Instead use this with the drill-down arrow operaters such as
-- ->.
--
-- using this as the only query filter is similar to the following in the
-- mongoDB shell
--
--
-- db.Collection.find({"object.field": item})
--
nestIn :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Filter record
infixr 4 `nestIn`
-- | The normal Persistent equality test ==. is not generic enough.
-- Instead use this with the drill-down arrow operaters such as
-- ->.
--
-- using this as the only query filter is similar to the following in the
-- mongoDB shell
--
--
-- db.Collection.find({"object.field": item})
--
nestNotIn :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Filter record
infixr 4 `nestNotIn`
-- | 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.
--
-- using this as the only query filter is similar to the following in the
-- mongoDB shell
--
--
-- db.Collection.find({arrayField: arrayItem})
--
anyEq :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> typ -> Filter record
infixr 4 `anyEq`
-- | 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 ~ MongoContext) => NestedField record [typ] -> typ -> Filter record
infixr 4 `nestAnyEq`
-- | same as nestEq, but give a BSON Value
nestBsonEq :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> Value -> Filter record
infixr 4 `nestBsonEq`
-- | same as anyEq, but give a BSON Value
anyBsonEq :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> Value -> Filter record
infixr 4 `anyBsonEq`
-- | Intersection of lists: if any value in the field is found in the list.
inList :: PersistField typ => EntityField v [typ] -> [typ] -> Filter v
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
infix 4 `ninList`
-- | Filter using a Regular expression.
(=~.) :: forall record searchable. (MongoRegexSearchable searchable, PersistEntity record, PersistEntityBackend record ~ MongoContext) => EntityField record searchable -> MongoRegex -> Filter record
infixr 4 =~.
data NestedField record typ
LastEmbFld :: EntityField record [emb] -> EntityField emb typ -> NestedField record typ
MidEmbFld :: EntityField record [emb] -> NestedField emb typ -> NestedField record typ
MidNestFlds :: EntityField record nest -> NestedField nest typ -> NestedField record typ
MidNestFldsNullable :: EntityField record (Maybe nest) -> NestedField nest typ -> NestedField record typ
LastNestFld :: EntityField record nest -> EntityField nest typ -> NestedField record typ
LastNestFldNullable :: EntityField record (Maybe nest) -> EntityField nest typ -> NestedField record typ
-- | Mark the subset of PersistFields that can be searched by a
-- mongoDB regex Anything stored as PersistText or an array of
-- PersistText would be valid
class PersistField typ => MongoRegexSearchable typ
-- | A MongoRegex represents a Regular expression. It is a tuple of the
-- expression and the options for the regular expression, respectively
-- Options are listed here:
-- http://docs.mongodb.org/manual/reference/operator/query/regex/
-- If you use the same options you may want to define a helper such as
-- r t = (t, "ims")
type MongoRegex = (Text, Text)
nestSet :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Update record
infixr 4 `nestSet`
nestInc :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Update record
nestDec :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Update record
nestMul :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Update record
push :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> typ -> Update record
infixr 4 `push`
pull :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> typ -> Update record
infixr 4 `pull`
pullAll :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> [typ] -> Update record
infixr 4 `pullAll`
addToSet :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> typ -> Update record
infixr 4 `addToSet`
-- | equivalent to $each
--
-- -- eachOp push field [] ---- -- eachOp pull will get translated to $pullAll eachOp :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => (EntityField record [typ] -> typ -> Update record) -> EntityField record [typ] -> [typ] -> Update record data family BackendKey backend :: Type keyToOid :: ToBackendKey MongoContext record => Key record -> ObjectId oidToKey :: ToBackendKey MongoContext record => ObjectId -> Key record recordTypeFromKey :: Key record -> record readMayObjectId :: Text -> Maybe ObjectId -- | Convert a Text to a Key readMayMongoKey :: Text -> Maybe (BackendKey MongoContext) keyToText :: BackendKey MongoContext -> Text fieldName :: forall record typ. PersistEntity record => EntityField record typ -> Label withConnection :: MonadIO m => MongoConf -> (ConnectionPool -> m b) -> m b withMongoPool :: MonadIO m => MongoConf -> (ConnectionPool -> m b) -> m b withMongoDBConn :: MonadIO m => Database -> HostName -> PortID -> Maybe MongoAuth -> NominalDiffTime -> (ConnectionPool -> m b) -> m b withMongoDBPool :: MonadIO m => Database -> HostName -> PortID -> Maybe MongoAuth -> Int -> Int -> NominalDiffTime -> (ConnectionPool -> m b) -> m b createMongoDBPool :: MonadIO m => Database -> HostName -> PortID -> Maybe MongoAuth -> Int -> Int -> NominalDiffTime -> m ConnectionPool runMongoDBPool :: MonadUnliftIO m => AccessMode -> Action m a -> ConnectionPool -> m a -- | use default AccessMode runMongoDBPoolDef :: MonadUnliftIO m => Action m a -> ConnectionPool -> m a type ConnectionPool = Pool Connection data Connection data MongoAuth MongoAuth :: Username -> Password -> MongoAuth -- | Information required to connect to a mongo database data MongoConf MongoConf :: Text -> Text -> PortID -> Maybe MongoAuth -> AccessMode -> Int -> Int -> NominalDiffTime -> Maybe ReplicaSetConfig -> MongoConf [mgDatabase] :: MongoConf -> Text [mgHost] :: MongoConf -> Text [mgPort] :: MongoConf -> PortID [mgAuth] :: MongoConf -> Maybe MongoAuth [mgAccessMode] :: MongoConf -> AccessMode [mgPoolStripes] :: MongoConf -> Int [mgStripeConnections] :: MongoConf -> Int [mgConnectionIdleTime] :: MongoConf -> NominalDiffTime -- | YAML fields for this are rsName and rsSecondaries -- mgHost is assumed to be the primary [mgReplicaSetConfig] :: MongoConf -> Maybe ReplicaSetConfig defaultMongoConf :: Text -> MongoConf defaultHost :: Text defaultAccessMode :: AccessMode defaultPoolStripes :: Int defaultConnectionIdleTime :: NominalDiffTime defaultStripeConnections :: Int -- | docker integration: change the host to the mongodb link applyDockerEnv :: MongoConf -> IO MongoConf type PipePool = Pool Pipe -- | A pool of plain MongoDB pipes. The database parameter has not yet been -- applied yet. This is useful for switching between databases (on the -- same host and port) Unlike the normal pool, no authentication is -- available createMongoDBPipePool :: MonadIO m => HostName -> PortID -> Int -> Int -> NominalDiffTime -> m PipePool -- | run a pool created with createMongoDBPipePool runMongoDBPipePool :: MonadUnliftIO m => AccessMode -> Database -> Action m a -> PipePool -> m a -- | Either a host name e.g., "haskell.org" or a numeric host -- address string consisting of a dotted decimal IPv4 address or an IPv6 -- address e.g., "192.168.0.1". type HostName = String type Database = Text -- | A monad on top of m (which must be a MonadIO) that may access the -- database and may fail with a DB Failure type Action = (ReaderT MongoContext :: Type -> Type -> Type -> Type) -- | Type of reads and writes to perform data AccessMode -- | Read-only action, reading stale data from a slave is OK. ReadStaleOk :: AccessMode -- | Read-write action, slave not OK, every write is fire & forget. UnconfirmedWrites :: AccessMode -- | Read-write action, slave not OK, every write is confirmed with -- getLastError. ConfirmWrites :: GetLastError -> AccessMode -- | Same as ConfirmWrites [] master :: AccessMode -- | Same as ReadStaleOk slaveOk :: AccessMode -- | Field with given label and typed value (=:) :: Val v => Label -> v -> Field infix 0 =: -- | A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp -- (seconds since epoch), a 3-byte machine id, a 2-byte process id, and a -- 3-byte counter. Note that the timestamp and counter fields must be -- stored big endian unlike the rest of BSON. This is because they are -- compared byte-by-byte and we want to ensure a mostly increasing order. data ObjectId -- | Values needed when executing a db operation data MongoContext -- | Wraps network's PortID Used to ease compatibility between older -- and newer network versions. data PortID instance GHC.Show.Show typ => GHC.Show.Show (Database.Persist.MongoDB.UpdateValueOp typ) instance GHC.Show.Show Database.Persist.MongoDB.MongoUpdateOperation instance GHC.Show.Show Database.Persist.MongoDB.MongoUpdateOperator instance GHC.Show.Show Database.Persist.MongoDB.MongoConf instance GHC.Show.Show Database.Persist.MongoDB.ReplicaSetConfig instance GHC.Show.Show Database.Persist.MongoDB.MongoAuth instance GHC.Show.Show Database.Persist.MongoDB.MultiFilter instance GHC.Classes.Eq Database.Persist.MongoDB.NoOrphanPortID instance GHC.Show.Show Database.Persist.MongoDB.NoOrphanPortID instance GHC.Num.Num Database.Persist.MongoDB.NoOrphanNominalDiffTime instance GHC.Classes.Eq Database.Persist.MongoDB.NoOrphanNominalDiffTime instance GHC.Show.Show Database.Persist.MongoDB.NoOrphanNominalDiffTime instance Database.Persist.Class.PersistField.PersistField (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance GHC.Classes.Ord (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance GHC.Classes.Eq (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance GHC.Read.Read (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance GHC.Show.Show (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance Database.Persist.MongoDB.MongoRegexSearchable Data.Text.Internal.Text instance Database.Persist.MongoDB.MongoRegexSearchable rs => Database.Persist.MongoDB.MongoRegexSearchable (GHC.Maybe.Maybe rs) instance Database.Persist.MongoDB.MongoRegexSearchable rs => Database.Persist.MongoDB.MongoRegexSearchable [rs] instance Data.Aeson.Types.FromJSON.FromJSON Database.Persist.MongoDB.MongoConf instance Database.Persist.Class.PersistConfig.PersistConfig Database.Persist.MongoDB.MongoConf instance Data.Aeson.Types.FromJSON.FromJSON Database.Persist.MongoDB.NoOrphanPortID instance Data.Aeson.Types.FromJSON.FromJSON Database.Persist.MongoDB.NoOrphanNominalDiffTime instance Database.Persist.Class.PersistStore.HasPersistBackend Database.MongoDB.Query.MongoContext instance Web.Internal.HttpApiData.ToHttpApiData (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance Web.Internal.HttpApiData.FromHttpApiData (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance Web.PathPieces.PathPiece (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance Database.Persist.Class.PersistField.PersistField Data.Bson.ObjectId instance Database.Persist.Sql.Class.PersistFieldSql Data.Bson.ObjectId instance Database.Persist.Sql.Class.PersistFieldSql (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance Data.Aeson.Types.ToJSON.ToJSON (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance Data.Aeson.Types.FromJSON.FromJSON (Database.Persist.Class.PersistStore.BackendKey Database.MongoDB.Query.MongoContext) instance Database.Persist.Class.PersistStore.PersistCore Database.MongoDB.Query.MongoContext instance Database.Persist.Class.PersistStore.PersistStoreWrite Database.MongoDB.Query.MongoContext instance Database.Persist.Class.PersistStore.PersistStoreRead Database.MongoDB.Query.MongoContext instance Database.Persist.Class.PersistUnique.PersistUniqueRead Database.MongoDB.Query.MongoContext instance Database.Persist.Class.PersistUnique.PersistUniqueWrite Database.MongoDB.Query.MongoContext instance Database.Persist.Class.PersistQuery.PersistQueryWrite Database.MongoDB.Query.MongoContext instance Database.Persist.Class.PersistQuery.PersistQueryRead Database.MongoDB.Query.MongoContext instance Data.Bson.Val Database.Persist.Types.Base.PersistValue instance Data.Serialize.Serialize Data.Bson.ObjectId