persistent-mongoDB-2.11.0.0: Backend for the persistent library using mongoDB.
Safe HaskellNone
LanguageHaskell2010

Database.Persist.MongoDB

Description

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.

Synopsis

Entity conversion

docToEntityEither :: forall record. PersistEntity record => Document -> Either Text (Entity record) Source #

docToEntityThrow :: forall m record. (MonadIO m, PersistEntity record, PersistEntityBackend record ~ MongoContext) => Document -> m (Entity record) Source #

recordToDocument :: (PersistEntity record, PersistEntityBackend record ~ MongoContext) => record -> Document Source #

convert a PersistEntity into document fields. unlike toInsertDoc, nulls are included.

toInsertDoc :: forall record. (PersistEntity record, PersistEntityBackend record ~ MongoContext) => record -> Document Source #

convert a PersistEntity into document fields. for inserts only: nulls are ignored so they will be unset in the document. recordToDocument includes nulls

entityToInsertDoc :: forall record. (PersistEntity record, PersistEntityBackend record ~ MongoContext) => Entity record -> Document Source #

toUniquesDoc :: forall record. PersistEntity record => Unique record -> [Field] Source #

convert a unique key into a MongoDB document

MongoDB specific queries

(->.) :: forall record emb typ. PersistEntity emb => EntityField record [emb] -> EntityField emb typ -> NestedField record typ infixr 6 Source #

Point to an array field with an embedded object and give a deeper query into the embedded object. Use with nestEq.

(~>.) :: forall record typ emb. PersistEntity emb => EntityField record [emb] -> NestedField emb typ -> NestedField record typ infixr 5 Source #

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 nest. PersistEntity nest => EntityField record (Maybe nest) -> EntityField nest typ -> NestedField record typ infixr 6 Source #

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 Source #

Same as &~>., but works against a Maybe type

(&->.) :: forall record typ nest. PersistEntity nest => EntityField record nest -> EntityField nest typ -> NestedField record typ infixr 6 Source #

Point to a nested field to query. This field is not an array type. Use with nestEq.

(&~>.) :: forall val nes nes1. PersistEntity nes1 => EntityField val nes1 -> NestedField nes1 nes -> NestedField val nes infixr 5 Source #

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.

Filters

You can find example usage for all of Persistent in our test cases: https://github.com/yesodweb/persistent/blob/master/persistent-test/EmbedTest.hs#L144

These filters create a query that reaches deeper into a document with nested fields.

nestEq :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Filter record infixr 4 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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 Source #

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})

anyEq :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> typ -> Filter record infixr 4 Source #

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})

nestAnyEq :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record [typ] -> typ -> Filter record infixr 4 Source #

Like nestEq, but for an embedded list. Checks to see if the nested list contains an item.

nestBsonEq :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> Value -> Filter record infixr 4 Source #

same as nestEq, but give a BSON Value

anyBsonEq :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> Value -> Filter record infixr 4 Source #

same as anyEq, but give a BSON Value

inList :: PersistField typ => EntityField v [typ] -> [typ] -> Filter v infix 4 Source #

Intersection of lists: if any value in the field is found in the list.

ninList :: PersistField typ => EntityField v [typ] -> [typ] -> Filter v infix 4 Source #

No intersection of lists: if no value in the field is found in the list.

(=~.) :: forall record searchable. (MongoRegexSearchable searchable, PersistEntity record, PersistEntityBackend record ~ MongoContext) => EntityField record searchable -> MongoRegex -> Filter record infixr 4 Source #

Filter using a Regular expression.

data NestedField record typ Source #

Constructors

forall emb.PersistEntity emb => (EntityField record [emb]) `LastEmbFld` (EntityField emb typ) 
forall emb.PersistEntity emb => (EntityField record [emb]) `MidEmbFld` (NestedField emb typ) 
forall nest.PersistEntity nest => (EntityField record nest) `MidNestFlds` (NestedField nest typ) 
forall nest.PersistEntity nest => (EntityField record (Maybe nest)) `MidNestFldsNullable` (NestedField nest typ) 
forall nest.PersistEntity nest => (EntityField record nest) `LastNestFld` (EntityField nest typ) 
forall nest.PersistEntity nest => (EntityField record (Maybe nest)) `LastNestFldNullable` (EntityField nest typ) 

class PersistField typ => MongoRegexSearchable typ Source #

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

Instances

Instances details
MongoRegexSearchable Text Source # 
Instance details

Defined in Database.Persist.MongoDB

MongoRegexSearchable rs => MongoRegexSearchable [rs] Source # 
Instance details

Defined in Database.Persist.MongoDB

MongoRegexSearchable rs => MongoRegexSearchable (Maybe rs) Source # 
Instance details

Defined in Database.Persist.MongoDB

type MongoRegex = (Text, Text) Source #

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")

Updates

nestSet :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Update record infixr 4 Source #

nestInc :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Update record Source #

nestDec :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Update record Source #

nestMul :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => NestedField record typ -> typ -> Update record Source #

push :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> typ -> Update record infixr 4 Source #

pull :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> typ -> Update record infixr 4 Source #

pullAll :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> [typ] -> Update record infixr 4 Source #

addToSet :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => EntityField record [typ] -> typ -> Update record infixr 4 Source #

eachOp :: forall record typ. (PersistField typ, PersistEntityBackend record ~ MongoContext) => (EntityField record [typ] -> typ -> Update record) -> EntityField record [typ] -> [typ] -> Update record Source #

equivalent to $each

eachOp push field []

eachOp pull will get translated to $pullAll

Key conversion helpers

data family BackendKey backend #

Instances

Instances details
Eq (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

Ord (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

Read (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

Show (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

ToJSON (BackendKey MongoContext) Source #

It would make sense to define the instance for ObjectId and then use newtype deriving however, that would create an orphan instance

Instance details

Defined in Database.Persist.MongoDB

FromJSON (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

ToHttpApiData (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

FromHttpApiData (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

PathPiece (BackendKey MongoContext) Source #

ToPathPiece is used to convert a key to/from text

Instance details

Defined in Database.Persist.MongoDB

PersistFieldSql (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

PersistField (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

newtype BackendKey MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

newtype BackendKey SqlBackend 
Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlReadBackend 
Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

newtype BackendKey SqlWriteBackend 
Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

type Rep (BackendKey SqlBackend) 
Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

type Rep (BackendKey SqlBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.11.0.0-3oHsDs9fiuzInxyZ8SMP1v" 'True) (C1 ('MetaCons "SqlBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))
type Rep (BackendKey SqlReadBackend) 
Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

type Rep (BackendKey SqlReadBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.11.0.0-3oHsDs9fiuzInxyZ8SMP1v" 'True) (C1 ('MetaCons "SqlReadBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlReadBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))
type Rep (BackendKey SqlWriteBackend) 
Instance details

Defined in Database.Persist.Sql.Orphan.PersistStore

type Rep (BackendKey SqlWriteBackend) = D1 ('MetaData "BackendKey" "Database.Persist.Sql.Orphan.PersistStore" "persistent-2.11.0.0-3oHsDs9fiuzInxyZ8SMP1v" 'True) (C1 ('MetaCons "SqlWriteBackendKey" 'PrefixI 'True) (S1 ('MetaSel ('Just "unSqlWriteBackendKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int64)))

recordTypeFromKey :: Key record -> record Source #

readMayMongoKey :: Text -> Maybe (BackendKey MongoContext) Source #

Convert a Text to a Key

PersistField conversion

fieldName :: forall record typ. PersistEntity record => EntityField record typ -> Label Source #

using connections

createMongoDBPool Source #

Arguments

:: MonadIO m 
=> Database 
-> HostName 
-> PortID 
-> Maybe MongoAuth 
-> Int

pool size (number of stripes)

-> Int

stripe size (number of connections per stripe)

-> NominalDiffTime

time a connection is left idle before closing

-> m ConnectionPool 

runMongoDBPoolDef :: MonadUnliftIO m => Action m a -> ConnectionPool -> m a Source #

use default AccessMode

data MongoAuth Source #

Instances

Instances details
Show MongoAuth Source # 
Instance details

Defined in Database.Persist.MongoDB

Connection configuration

data MongoConf Source #

Information required to connect to a mongo database

Constructors

MongoConf 

Fields

applyDockerEnv :: MongoConf -> IO MongoConf Source #

docker integration: change the host to the mongodb link

using raw MongoDB pipes

createMongoDBPipePool Source #

Arguments

:: MonadIO m 
=> HostName 
-> PortID 
-> Int

pool size (number of stripes)

-> Int

stripe size (number of connections per stripe)

-> NominalDiffTime

time a connection is left idle before closing

-> m PipePool 

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

network type

type HostName = String #

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".

MongoDB driver types

type Database = Text #

type Action = ReaderT MongoContext #

A monad on top of m (which must be a MonadIO) that may access the database and may fail with a DB Failure

data AccessMode #

Type of reads and writes to perform

Constructors

ReadStaleOk

Read-only action, reading stale data from a slave is OK.

UnconfirmedWrites

Read-write action, slave not OK, every write is fire & forget.

ConfirmWrites GetLastError

Read-write action, slave not OK, every write is confirmed with getLastError.

Instances

Instances details
Show AccessMode 
Instance details

Defined in Database.MongoDB.Query

(=:) :: Val v => Label -> v -> Field infix 0 #

Field with given label and typed value

data ObjectId #

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.

Instances

Instances details
Eq ObjectId 
Instance details

Defined in Data.Bson

Ord ObjectId 
Instance details

Defined in Data.Bson

Read ObjectId 
Instance details

Defined in Data.Bson

Show ObjectId 
Instance details

Defined in Data.Bson

Val ObjectId 
Instance details

Defined in Data.Bson

Serialize ObjectId Source # 
Instance details

Defined in Database.Persist.MongoDB

PersistFieldSql ObjectId Source # 
Instance details

Defined in Database.Persist.MongoDB

PersistField ObjectId Source # 
Instance details

Defined in Database.Persist.MongoDB

data MongoContext #

Values needed when executing a db operation

Instances

Instances details
HasMongoContext MongoContext 
Instance details

Defined in Database.MongoDB.Query

PersistQueryRead MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

Methods

selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (PersistRecordBackend record MongoContext, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT MongoContext m1 (Acquire (ConduitM () (Entity record) m2 ())) #

selectFirst :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> [SelectOpt record] -> ReaderT MongoContext m (Maybe (Entity record)) #

selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (MonadIO m1, MonadIO m2, PersistRecordBackend record MongoContext) => [Filter record] -> [SelectOpt record] -> ReaderT MongoContext m1 (Acquire (ConduitM () (Key record) m2 ())) #

count :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> ReaderT MongoContext m Int #

exists :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> ReaderT MongoContext m Bool #

PersistQueryWrite MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

Methods

updateWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> [Update record] -> ReaderT MongoContext m () #

deleteWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> ReaderT MongoContext m () #

PersistUniqueRead MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

Methods

getBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Unique record -> ReaderT MongoContext m (Maybe (Entity record)) #

PersistUniqueWrite MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

Methods

deleteBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Unique record -> ReaderT MongoContext m () #

insertUnique :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => record -> ReaderT MongoContext m (Maybe (Key record)) #

upsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext, OnlyOneUniqueKey record) => record -> [Update record] -> ReaderT MongoContext m (Entity record) #

upsertBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Unique record -> record -> [Update record] -> ReaderT MongoContext m (Entity record) #

putMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [record] -> ReaderT MongoContext m () #

HasPersistBackend MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

Associated Types

type BaseBackend MongoContext #

PersistCore MongoContext Source #

older versions versions of haddock (like that on hackage) do not show that this defines BackendKey DB.MongoContext = MongoKey { unMongoKey :: DB.ObjectId }

Instance details

Defined in Database.Persist.MongoDB

Associated Types

data BackendKey MongoContext #

PersistStoreRead MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

Methods

get :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> ReaderT MongoContext m (Maybe record) #

getMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [Key record] -> ReaderT MongoContext m (Map (Key record) record) #

PersistStoreWrite MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

Methods

insert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => record -> ReaderT MongoContext m (Key record) #

insert_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => record -> ReaderT MongoContext m () #

insertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [record] -> ReaderT MongoContext m [Key record] #

insertMany_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [record] -> ReaderT MongoContext m () #

insertEntityMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [Entity record] -> ReaderT MongoContext m () #

insertKey :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> record -> ReaderT MongoContext m () #

repsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> record -> ReaderT MongoContext m () #

repsertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [(Key record, record)] -> ReaderT MongoContext m () #

replace :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> record -> ReaderT MongoContext m () #

delete :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> ReaderT MongoContext m () #

update :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> [Update record] -> ReaderT MongoContext m () #

updateGet :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> [Update record] -> ReaderT MongoContext m record #

Eq (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

Ord (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

Read (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

Show (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

ToJSON (BackendKey MongoContext) Source #

It would make sense to define the instance for ObjectId and then use newtype deriving however, that would create an orphan instance

Instance details

Defined in Database.Persist.MongoDB

FromJSON (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

ToHttpApiData (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

FromHttpApiData (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

PathPiece (BackendKey MongoContext) Source #

ToPathPiece is used to convert a key to/from text

Instance details

Defined in Database.Persist.MongoDB

PersistFieldSql (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

PersistField (BackendKey MongoContext) Source # 
Instance details

Defined in Database.Persist.MongoDB

type BaseBackend MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

newtype BackendKey MongoContext Source # 
Instance details

Defined in Database.Persist.MongoDB

type BackendSpecificUpdate MongoContext record Source # 
Instance details

Defined in Database.Persist.MongoDB

type BackendSpecificFilter MongoContext record Source # 
Instance details

Defined in Database.Persist.MongoDB

data PortID #

Wraps network's PortNumber Used to ease compatibility between older and newer network versions.

Instances

Instances details
Eq PortID 
Instance details

Defined in Database.MongoDB.Internal.Network

Methods

(==) :: PortID -> PortID -> Bool #

(/=) :: PortID -> PortID -> Bool #

Ord PortID 
Instance details

Defined in Database.MongoDB.Internal.Network

Show PortID 
Instance details

Defined in Database.MongoDB.Internal.Network

Database.Persist

Orphan instances

Val PersistValue Source # 
Instance details

Serialize ObjectId Source # 
Instance details

PersistFieldSql ObjectId Source # 
Instance details

PersistQueryRead MongoContext Source # 
Instance details

Methods

selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (PersistRecordBackend record MongoContext, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT MongoContext m1 (Acquire (ConduitM () (Entity record) m2 ())) #

selectFirst :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> [SelectOpt record] -> ReaderT MongoContext m (Maybe (Entity record)) #

selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (MonadIO m1, MonadIO m2, PersistRecordBackend record MongoContext) => [Filter record] -> [SelectOpt record] -> ReaderT MongoContext m1 (Acquire (ConduitM () (Key record) m2 ())) #

count :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> ReaderT MongoContext m Int #

exists :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> ReaderT MongoContext m Bool #

PersistQueryWrite MongoContext Source # 
Instance details

Methods

updateWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> [Update record] -> ReaderT MongoContext m () #

deleteWhere :: forall (m :: Type -> Type) record. (MonadIO m, PersistRecordBackend record MongoContext) => [Filter record] -> ReaderT MongoContext m () #

PersistUniqueRead MongoContext Source # 
Instance details

Methods

getBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Unique record -> ReaderT MongoContext m (Maybe (Entity record)) #

PersistUniqueWrite MongoContext Source # 
Instance details

Methods

deleteBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Unique record -> ReaderT MongoContext m () #

insertUnique :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => record -> ReaderT MongoContext m (Maybe (Key record)) #

upsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext, OnlyOneUniqueKey record) => record -> [Update record] -> ReaderT MongoContext m (Entity record) #

upsertBy :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Unique record -> record -> [Update record] -> ReaderT MongoContext m (Entity record) #

putMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [record] -> ReaderT MongoContext m () #

HasPersistBackend MongoContext Source # 
Instance details

Associated Types

type BaseBackend MongoContext #

PersistCore MongoContext Source #

older versions versions of haddock (like that on hackage) do not show that this defines BackendKey DB.MongoContext = MongoKey { unMongoKey :: DB.ObjectId }

Instance details

Associated Types

data BackendKey MongoContext #

PersistStoreRead MongoContext Source # 
Instance details

Methods

get :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> ReaderT MongoContext m (Maybe record) #

getMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [Key record] -> ReaderT MongoContext m (Map (Key record) record) #

PersistStoreWrite MongoContext Source # 
Instance details

Methods

insert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => record -> ReaderT MongoContext m (Key record) #

insert_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => record -> ReaderT MongoContext m () #

insertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [record] -> ReaderT MongoContext m [Key record] #

insertMany_ :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [record] -> ReaderT MongoContext m () #

insertEntityMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [Entity record] -> ReaderT MongoContext m () #

insertKey :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> record -> ReaderT MongoContext m () #

repsert :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> record -> ReaderT MongoContext m () #

repsertMany :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => [(Key record, record)] -> ReaderT MongoContext m () #

replace :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> record -> ReaderT MongoContext m () #

delete :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> ReaderT MongoContext m () #

update :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> [Update record] -> ReaderT MongoContext m () #

updateGet :: forall record (m :: Type -> Type). (MonadIO m, PersistRecordBackend record MongoContext) => Key record -> [Update record] -> ReaderT MongoContext m record #

PersistField ObjectId Source # 
Instance details

Eq (BackendKey MongoContext) Source # 
Instance details

Ord (BackendKey MongoContext) Source # 
Instance details

Read (BackendKey MongoContext) Source # 
Instance details

Show (BackendKey MongoContext) Source # 
Instance details

ToJSON (BackendKey MongoContext) Source #

It would make sense to define the instance for ObjectId and then use newtype deriving however, that would create an orphan instance

Instance details

FromJSON (BackendKey MongoContext) Source # 
Instance details

ToHttpApiData (BackendKey MongoContext) Source # 
Instance details

FromHttpApiData (BackendKey MongoContext) Source # 
Instance details

PathPiece (BackendKey MongoContext) Source #

ToPathPiece is used to convert a key to/from text

Instance details

PersistFieldSql (BackendKey MongoContext) Source # 
Instance details

PersistField (BackendKey MongoContext) Source # 
Instance details