persistent-2.10.5.2: Type-safe, multi-backend data serialization.
Safe HaskellNone
LanguageHaskell2010

Database.Persist.Types

Synopsis

Documentation

data Checkmark Source #

A Checkmark should be used as a field type whenever a uniqueness constraint should guarantee that a certain kind of record may appear at most once, but other kinds of records may appear any number of times.

NOTE: You need to mark any Checkmark fields as nullable (see the following example).

For example, suppose there's a Location entity that represents where a user has lived:

Location
    user    UserId
    name    Text
    current Checkmark nullable

    UniqueLocation user current

The UniqueLocation constraint allows any number of Inactive Locations to be current. However, there may be at most one current Location per user (i.e., either zero or one per user).

This data type works because of the way that SQL treats NULLable fields within uniqueness constraints. The SQL standard says that NULL values should be considered different, so we represent Inactive as SQL NULL, thus allowing any number of Inactive records. On the other hand, we represent Active as TRUE, so the uniqueness constraint will disallow more than one Active record.

Note: There may be DBMSs that do not respect the SQL standard's treatment of NULL values on uniqueness constraints, please check if this data type works before relying on it.

The SQL BOOLEAN type is used because it's the smallest data type available. Note that we never use FALSE, just TRUE and NULL. Provides the same behavior Maybe () would if () was a valid PersistField.

Constructors

Active

When used on a uniqueness constraint, there may be at most one Active record.

Inactive

When used on a uniqueness constraint, there may be any number of Inactive records.

Instances

Instances details
Bounded Checkmark Source # 
Instance details

Defined in Database.Persist.Types.Base

Enum Checkmark Source # 
Instance details

Defined in Database.Persist.Types.Base

Eq Checkmark Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: Checkmark -> Checkmark -> Bool

(/=) :: Checkmark -> Checkmark -> Bool

Ord Checkmark Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

compare :: Checkmark -> Checkmark -> Ordering

(<) :: Checkmark -> Checkmark -> Bool

(<=) :: Checkmark -> Checkmark -> Bool

(>) :: Checkmark -> Checkmark -> Bool

(>=) :: Checkmark -> Checkmark -> Bool

max :: Checkmark -> Checkmark -> Checkmark

min :: Checkmark -> Checkmark -> Checkmark

Read Checkmark Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS Checkmark

readList :: ReadS [Checkmark]

readPrec :: ReadPrec Checkmark

readListPrec :: ReadPrec [Checkmark]

Show Checkmark Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> Checkmark -> ShowS

show :: Checkmark -> String

showList :: [Checkmark] -> ShowS

ToHttpApiData Checkmark Source # 
Instance details

Defined in Database.Persist.Types.Base

FromHttpApiData Checkmark Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

parseUrlPiece :: Text -> Either Text Checkmark Source #

parseHeader :: ByteString -> Either Text Checkmark Source #

parseQueryParam :: Text -> Either Text Checkmark Source #

PathPiece Checkmark Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

fromPathPiece :: Text -> Maybe Checkmark Source #

toPathPiece :: Checkmark -> Text Source #

PersistField Checkmark Source # 
Instance details

Defined in Database.Persist.Class.PersistField

PersistFieldSql Checkmark Source # 
Instance details

Defined in Database.Persist.Sql.Class

Methods

sqlType :: Proxy Checkmark -> SqlType Source #

data IsNullable Source #

Instances

Instances details
Eq IsNullable Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: IsNullable -> IsNullable -> Bool

(/=) :: IsNullable -> IsNullable -> Bool

Show IsNullable Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> IsNullable -> ShowS

show :: IsNullable -> String

showList :: [IsNullable] -> ShowS

data WhyNullable Source #

The reason why a field is nullable is very important. A field that is nullable because of a Maybe tag will have its type changed from A to Maybe A. OTOH, a field that is nullable because of a nullable tag will remain with the same type.

Instances

Instances details
Eq WhyNullable Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: WhyNullable -> WhyNullable -> Bool

(/=) :: WhyNullable -> WhyNullable -> Bool

Show WhyNullable Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> WhyNullable -> ShowS

show :: WhyNullable -> String

showList :: [WhyNullable] -> ShowS

data EntityDef Source #

An EntityDef represents the information that persistent knows about an Entity. It uses this information to generate the Haskell datatype, the SQL migrations, and other relevant conversions.

Constructors

EntityDef 

Fields

Instances

Instances details
Eq EntityDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: EntityDef -> EntityDef -> Bool

(/=) :: EntityDef -> EntityDef -> Bool

Ord EntityDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

compare :: EntityDef -> EntityDef -> Ordering

(<) :: EntityDef -> EntityDef -> Bool

(<=) :: EntityDef -> EntityDef -> Bool

(>) :: EntityDef -> EntityDef -> Bool

(>=) :: EntityDef -> EntityDef -> Bool

max :: EntityDef -> EntityDef -> EntityDef

min :: EntityDef -> EntityDef -> EntityDef

Read EntityDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS EntityDef

readList :: ReadS [EntityDef]

readPrec :: ReadPrec EntityDef

readListPrec :: ReadPrec [EntityDef]

Show EntityDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> EntityDef -> ShowS

show :: EntityDef -> String

showList :: [EntityDef] -> ShowS

type ExtraLine = [Text] Source #

newtype HaskellName Source #

Constructors

HaskellName 

Fields

Instances

Instances details
Eq HaskellName Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: HaskellName -> HaskellName -> Bool

(/=) :: HaskellName -> HaskellName -> Bool

Ord HaskellName Source # 
Instance details

Defined in Database.Persist.Types.Base

Read HaskellName Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS HaskellName

readList :: ReadS [HaskellName]

readPrec :: ReadPrec HaskellName

readListPrec :: ReadPrec [HaskellName]

Show HaskellName Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> HaskellName -> ShowS

show :: HaskellName -> String

showList :: [HaskellName] -> ShowS

newtype DBName Source #

Constructors

DBName 

Fields

Instances

Instances details
Eq DBName Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: DBName -> DBName -> Bool

(/=) :: DBName -> DBName -> Bool

Ord DBName Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

compare :: DBName -> DBName -> Ordering

(<) :: DBName -> DBName -> Bool

(<=) :: DBName -> DBName -> Bool

(>) :: DBName -> DBName -> Bool

(>=) :: DBName -> DBName -> Bool

max :: DBName -> DBName -> DBName

min :: DBName -> DBName -> DBName

Read DBName Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS DBName

readList :: ReadS [DBName]

readPrec :: ReadPrec DBName

readListPrec :: ReadPrec [DBName]

Show DBName Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> DBName -> ShowS

show :: DBName -> String

showList :: [DBName] -> ShowS

type Attr = Text Source #

data FieldType Source #

Constructors

FTTypeCon (Maybe Text) Text

Optional module and name.

FTApp FieldType FieldType 
FTList FieldType 

Instances

Instances details
Eq FieldType Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: FieldType -> FieldType -> Bool

(/=) :: FieldType -> FieldType -> Bool

Ord FieldType Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

compare :: FieldType -> FieldType -> Ordering

(<) :: FieldType -> FieldType -> Bool

(<=) :: FieldType -> FieldType -> Bool

(>) :: FieldType -> FieldType -> Bool

(>=) :: FieldType -> FieldType -> Bool

max :: FieldType -> FieldType -> FieldType

min :: FieldType -> FieldType -> FieldType

Read FieldType Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS FieldType

readList :: ReadS [FieldType]

readPrec :: ReadPrec FieldType

readListPrec :: ReadPrec [FieldType]

Show FieldType Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> FieldType -> ShowS

show :: FieldType -> String

showList :: [FieldType] -> ShowS

data FieldDef Source #

A FieldDef represents the inormation that persistent knows about a field of a datatype. This includes information used to parse the field out of the database and what the field corresponds to.

Constructors

FieldDef 

Fields

  • fieldHaskell :: !HaskellName

    The name of the field. Note that this does not corresponds to the record labels generated for the particular entity - record labels are generated with the type name prefixed to the field, so a FieldDef that contains a HaskellName "name" for a type User will have a record field userName.

  • fieldDB :: !DBName

    The name of the field in the database. For SQL databases, this corresponds to the column name.

  • fieldType :: !FieldType

    The type of the field in Haskell.

  • fieldSqlType :: !SqlType

    The type of the field in a SQL database.

  • fieldAttrs :: ![Attr]

    User annotations for a field. These are provided with the ! operator.

  • fieldStrict :: !Bool

    If this is True, then the Haskell datatype will have a strict record field. The default value for this is True.

  • fieldReference :: !ReferenceDef
     
  • fieldComments :: !(Maybe Text)

    Optional comments for a Field. There is not currently a way to attach comments to a field in the quasiquoter.

    Since: 2.10.0

Instances

Instances details
Eq FieldDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: FieldDef -> FieldDef -> Bool

(/=) :: FieldDef -> FieldDef -> Bool

Ord FieldDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

compare :: FieldDef -> FieldDef -> Ordering

(<) :: FieldDef -> FieldDef -> Bool

(<=) :: FieldDef -> FieldDef -> Bool

(>) :: FieldDef -> FieldDef -> Bool

(>=) :: FieldDef -> FieldDef -> Bool

max :: FieldDef -> FieldDef -> FieldDef

min :: FieldDef -> FieldDef -> FieldDef

Read FieldDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS FieldDef

readList :: ReadS [FieldDef]

readPrec :: ReadPrec FieldDef

readListPrec :: ReadPrec [FieldDef]

Show FieldDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> FieldDef -> ShowS

show :: FieldDef -> String

showList :: [FieldDef] -> ShowS

data ReferenceDef Source #

There are 3 kinds of references 1) composite (to fields that exist in the record) 2) single field 3) embedded

Constructors

NoReference 
ForeignRef !HaskellName !FieldType

A ForeignRef has a late binding to the EntityDef it references via HaskellName and has the Haskell type of the foreign key in the form of FieldType

EmbedRef EmbedEntityDef 
CompositeRef CompositeDef 
SelfReference

A SelfReference stops an immediate cycle which causes non-termination at compile-time (issue #311).

Instances

Instances details
Eq ReferenceDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: ReferenceDef -> ReferenceDef -> Bool

(/=) :: ReferenceDef -> ReferenceDef -> Bool

Ord ReferenceDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Read ReferenceDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS ReferenceDef

readList :: ReadS [ReferenceDef]

readPrec :: ReadPrec ReferenceDef

readListPrec :: ReadPrec [ReferenceDef]

Show ReferenceDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> ReferenceDef -> ShowS

show :: ReferenceDef -> String

showList :: [ReferenceDef] -> ShowS

data EmbedEntityDef Source #

An EmbedEntityDef is the same as an EntityDef But it is only used for fieldReference so it only has data needed for embedding

Instances

Instances details
Eq EmbedEntityDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Ord EmbedEntityDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Read EmbedEntityDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS EmbedEntityDef

readList :: ReadS [EmbedEntityDef]

readPrec :: ReadPrec EmbedEntityDef

readListPrec :: ReadPrec [EmbedEntityDef]

Show EmbedEntityDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> EmbedEntityDef -> ShowS

show :: EmbedEntityDef -> String

showList :: [EmbedEntityDef] -> ShowS

data EmbedFieldDef Source #

An EmbedFieldDef is the same as a FieldDef But it is only used for embeddedFields so it only has data needed for embedding

Constructors

EmbedFieldDef 

Fields

Instances

Instances details
Eq EmbedFieldDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Ord EmbedFieldDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Read EmbedFieldDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS EmbedFieldDef

readList :: ReadS [EmbedFieldDef]

readPrec :: ReadPrec EmbedFieldDef

readListPrec :: ReadPrec [EmbedFieldDef]

Show EmbedFieldDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> EmbedFieldDef -> ShowS

show :: EmbedFieldDef -> String

showList :: [EmbedFieldDef] -> ShowS

data UniqueDef Source #

Instances

Instances details
Eq UniqueDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: UniqueDef -> UniqueDef -> Bool

(/=) :: UniqueDef -> UniqueDef -> Bool

Ord UniqueDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

compare :: UniqueDef -> UniqueDef -> Ordering

(<) :: UniqueDef -> UniqueDef -> Bool

(<=) :: UniqueDef -> UniqueDef -> Bool

(>) :: UniqueDef -> UniqueDef -> Bool

(>=) :: UniqueDef -> UniqueDef -> Bool

max :: UniqueDef -> UniqueDef -> UniqueDef

min :: UniqueDef -> UniqueDef -> UniqueDef

Read UniqueDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS UniqueDef

readList :: ReadS [UniqueDef]

readPrec :: ReadPrec UniqueDef

readListPrec :: ReadPrec [UniqueDef]

Show UniqueDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> UniqueDef -> ShowS

show :: UniqueDef -> String

showList :: [UniqueDef] -> ShowS

data CompositeDef Source #

Constructors

CompositeDef 

Instances

Instances details
Eq CompositeDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: CompositeDef -> CompositeDef -> Bool

(/=) :: CompositeDef -> CompositeDef -> Bool

Ord CompositeDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Read CompositeDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS CompositeDef

readList :: ReadS [CompositeDef]

readPrec :: ReadPrec CompositeDef

readListPrec :: ReadPrec [CompositeDef]

Show CompositeDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> CompositeDef -> ShowS

show :: CompositeDef -> String

showList :: [CompositeDef] -> ShowS

type ForeignFieldDef = (HaskellName, DBName) Source #

Used instead of FieldDef to generate a smaller amount of code

data ForeignDef Source #

Instances

Instances details
Eq ForeignDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: ForeignDef -> ForeignDef -> Bool

(/=) :: ForeignDef -> ForeignDef -> Bool

Ord ForeignDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Read ForeignDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS ForeignDef

readList :: ReadS [ForeignDef]

readPrec :: ReadPrec ForeignDef

readListPrec :: ReadPrec [ForeignDef]

Show ForeignDef Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> ForeignDef -> ShowS

show :: ForeignDef -> String

showList :: [ForeignDef] -> ShowS

data PersistValue Source #

A raw value which can be stored in any backend and can be marshalled to and from a PersistField.

Constructors

PersistText Text 
PersistByteString ByteString 
PersistInt64 Int64 
PersistDouble Double 
PersistRational Rational 
PersistBool Bool 
PersistDay Day 
PersistTimeOfDay TimeOfDay 
PersistUTCTime UTCTime 
PersistNull 
PersistList [PersistValue] 
PersistMap [(Text, PersistValue)] 
PersistObjectId ByteString

Intended especially for MongoDB backend

PersistArray [PersistValue]

Intended especially for PostgreSQL backend for text arrays

PersistDbSpecific ByteString

Using PersistDbSpecific allows you to use types specific to a particular backend For example, below is a simple example of the PostGIS geography type:

data Geo = Geo ByteString

instance PersistField Geo where
  toPersistValue (Geo t) = PersistDbSpecific t

  fromPersistValue (PersistDbSpecific t) = Right $ Geo $ Data.ByteString.concat ["'", t, "'"]
  fromPersistValue _ = Left "Geo values must be converted from PersistDbSpecific"

instance PersistFieldSql Geo where
  sqlType _ = SqlOther "GEOGRAPHY(POINT,4326)"

toPoint :: Double -> Double -> Geo
toPoint lat lon = Geo $ Data.ByteString.concat ["'POINT(", ps $ lon, " ", ps $ lat, ")'"]
  where ps = Data.Text.pack . show

If Foo has a geography field, we can then perform insertions like the following:

insert $ Foo (toPoint 44 44)

Instances

Instances details
Eq PersistValue Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: PersistValue -> PersistValue -> Bool

(/=) :: PersistValue -> PersistValue -> Bool

Ord PersistValue Source # 
Instance details

Defined in Database.Persist.Types.Base

Read PersistValue Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS PersistValue

readList :: ReadS [PersistValue]

readPrec :: ReadPrec PersistValue

readListPrec :: ReadPrec [PersistValue]

Show PersistValue Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> PersistValue -> ShowS

show :: PersistValue -> String

showList :: [PersistValue] -> ShowS

ToJSON PersistValue Source # 
Instance details

Defined in Database.Persist.Types.Base

FromJSON PersistValue Source # 
Instance details

Defined in Database.Persist.Types.Base

ToHttpApiData PersistValue Source # 
Instance details

Defined in Database.Persist.Types.Base

FromHttpApiData PersistValue Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

parseUrlPiece :: Text -> Either Text PersistValue Source #

parseHeader :: ByteString -> Either Text PersistValue Source #

parseQueryParam :: Text -> Either Text PersistValue Source #

PathPiece PersistValue Source # 
Instance details

Defined in Database.Persist.Types.Base

PersistField PersistValue Source # 
Instance details

Defined in Database.Persist.Class.PersistField

PersistFieldSql PersistValue Source # 
Instance details

Defined in Database.Persist.Sql.Class

Methods

sqlType :: Proxy PersistValue -> SqlType Source #

fromPersistValueText :: PersistValue -> Either Text Text Source #

data SqlType Source #

A SQL data type. Naming attempts to reflect the underlying Haskell datatypes, eg SqlString instead of SqlVarchar. Different SQL databases may have different translations for these types.

Constructors

SqlString 
SqlInt32 
SqlInt64 
SqlReal 
SqlNumeric Word32 Word32 
SqlBool 
SqlDay 
SqlTime 
SqlDayTime

Always uses UTC timezone

SqlBlob 
SqlOther Text

a backend-specific name

Instances

Instances details
Eq SqlType Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

(==) :: SqlType -> SqlType -> Bool

(/=) :: SqlType -> SqlType -> Bool

Ord SqlType Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

compare :: SqlType -> SqlType -> Ordering

(<) :: SqlType -> SqlType -> Bool

(<=) :: SqlType -> SqlType -> Bool

(>) :: SqlType -> SqlType -> Bool

(>=) :: SqlType -> SqlType -> Bool

max :: SqlType -> SqlType -> SqlType

min :: SqlType -> SqlType -> SqlType

Read SqlType Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS SqlType

readList :: ReadS [SqlType]

readPrec :: ReadPrec SqlType

readListPrec :: ReadPrec [SqlType]

Show SqlType Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> SqlType -> ShowS

show :: SqlType -> String

showList :: [SqlType] -> ShowS

data PersistFilter Source #

Constructors

Eq 
Ne 
Gt 
Lt 
Ge 
Le 
In 
NotIn 
BackendSpecificFilter Text 

Instances

Instances details
Read PersistFilter Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS PersistFilter

readList :: ReadS [PersistFilter]

readPrec :: ReadPrec PersistFilter

readListPrec :: ReadPrec [PersistFilter]

Show PersistFilter Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> PersistFilter -> ShowS

show :: PersistFilter -> String

showList :: [PersistFilter] -> ShowS

data UpdateException Source #

Constructors

KeyNotFound String 
UpsertError String 

Instances

Instances details
Show UpdateException Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> UpdateException -> ShowS

show :: UpdateException -> String

showList :: [UpdateException] -> ShowS

Exception UpdateException Source # 
Instance details

Defined in Database.Persist.Types.Base

data PersistUpdate Source #

Instances

Instances details
Read PersistUpdate Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

readsPrec :: Int -> ReadS PersistUpdate

readList :: ReadS [PersistUpdate]

readPrec :: ReadPrec PersistUpdate

readListPrec :: ReadPrec [PersistUpdate]

Show PersistUpdate Source # 
Instance details

Defined in Database.Persist.Types.Base

Methods

showsPrec :: Int -> PersistUpdate -> ShowS

show :: PersistUpdate -> String

showList :: [PersistUpdate] -> ShowS

data Update record Source #

Updating a database entity.

Persistent users use combinators to create these.

Constructors

forall typ.PersistField typ => Update 
BackendUpdate (BackendSpecificUpdate (PersistEntityBackend record) record) 

type family BackendSpecificUpdate backend record Source #

data SelectOpt record Source #

Query options.

Persistent users use these directly.

Constructors

forall typ. Asc (EntityField record typ) 
forall typ. Desc (EntityField record typ) 
OffsetBy Int 
LimitTo Int 

data Filter record Source #

Filters which are available for select, updateWhere and deleteWhere. Each filter constructor specifies the field being filtered on, the type of comparison applied (equals, not equals, etc) and the argument for the comparison.

Persistent users use combinators to create these.

Note that it's important to be careful about the PersistFilter that you are using, if you use this directly. For example, using the In PersistFilter requires that you have an array- or list-shaped EntityField. It is possible to construct values using this that will create malformed runtime values.

Constructors

forall typ.PersistField typ => Filter 
FilterAnd [Filter record]

convenient for internal use, not needed for the API

FilterOr [Filter record] 
BackendFilter (BackendSpecificFilter (PersistEntityBackend record) record) 

data FilterValue typ where Source #

Value to filter with. Highly dependant on the type of filter used.

Since: 2.10.0

Constructors

FilterValue :: typ -> FilterValue typ 
FilterValues :: [typ] -> FilterValue typ 
UnsafeValue :: forall a typ. PersistField a => a -> FilterValue typ 

type family BackendSpecificFilter backend record Source #

data family Key record Source #

By default, a backend will automatically generate the key Instead you can specify a Primary key made up of unique values.

Instances

Instances details
(PersistEntity a, PersistEntityBackend a ~ backend, IsPersistBackend backend) => RawSql (Key a) Source # 
Instance details

Defined in Database.Persist.Sql.Class

Methods

rawSqlCols :: (DBName -> Text) -> Key a -> (Int, [Text]) Source #

rawSqlColCountReason :: Key a -> String Source #

rawSqlProcessRow :: [PersistValue] -> Either Text (Key a) Source #

data Entity record Source #

Datatype that represents an entity, with both its Key and its Haskell record representation.

When using a SQL-based backend (such as SQLite or PostgreSQL), an Entity may take any number of columns depending on how many fields it has. In order to reconstruct your entity on the Haskell side, persistent needs all of your entity columns and in the right order. Note that you don't need to worry about this when using persistent's API since everything is handled correctly behind the scenes.

However, if you want to issue a raw SQL command that returns an Entity, then you have to be careful with the column order. While you could use SELECT Entity.* WHERE ... and that would work most of the time, there are times when the order of the columns on your database is different from the order that persistent expects (for example, if you add a new field in the middle of you entity definition and then use the migration code -- persistent will expect the column to be in the middle, but your DBMS will put it as the last column). So, instead of using a query like the one above, you may use rawSql (from the Database.Persist.GenericSql module) with its /entity selection placeholder/ (a double question mark ??). Using rawSql the query above must be written as SELECT ?? WHERE ... Then rawSql will replace ?? with the list of all columns that we need from your entity in the right order. If your query returns two entities (i.e. (Entity backend a, Entity backend b)), then you must you use SELECT ??, ?? WHERE ..., and so on.

Constructors

Entity 

Fields

Instances

Instances details
(Eq (Key record), Eq record) => Eq (Entity record) Source # 
Instance details

Defined in Database.Persist.Class.PersistEntity

Methods

(==) :: Entity record -> Entity record -> Bool

(/=) :: Entity record -> Entity record -> Bool

(Ord (Key record), Ord record) => Ord (Entity record) Source # 
Instance details

Defined in Database.Persist.Class.PersistEntity

Methods

compare :: Entity record -> Entity record -> Ordering

(<) :: Entity record -> Entity record -> Bool

(<=) :: Entity record -> Entity record -> Bool

(>) :: Entity record -> Entity record -> Bool

(>=) :: Entity record -> Entity record -> Bool

max :: Entity record -> Entity record -> Entity record

min :: Entity record -> Entity record -> Entity record

(Read (Key record), Read record) => Read (Entity record) Source # 
Instance details

Defined in Database.Persist.Class.PersistEntity

Methods

readsPrec :: Int -> ReadS (Entity record)

readList :: ReadS [Entity record]

readPrec :: ReadPrec (Entity record)

readListPrec :: ReadPrec [Entity record]

(Show (Key record), Show record) => Show (Entity record) Source # 
Instance details

Defined in Database.Persist.Class.PersistEntity

Methods

showsPrec :: Int -> Entity record -> ShowS

show :: Entity record -> String

showList :: [Entity record] -> ShowS

(Generic (Key record), Generic record) => Generic (Entity record) Source # 
Instance details

Defined in Database.Persist.Class.PersistEntity

Associated Types

type Rep (Entity record) :: Type -> Type

Methods

from :: Entity record -> Rep (Entity record) x

to :: Rep (Entity record) x -> Entity record

(PersistEntity record, PersistField record, PersistField (Key record)) => PersistField (Entity record) Source # 
Instance details

Defined in Database.Persist.Class.PersistEntity

Methods

toPersistValue :: Entity record -> PersistValue Source #

fromPersistValue :: PersistValue -> Either Text (Entity record) Source #

(PersistField record, PersistEntity record) => PersistFieldSql (Entity record) Source # 
Instance details

Defined in Database.Persist.Sql.Class

Methods

sqlType :: Proxy (Entity record) -> SqlType Source #

(PersistEntity record, PersistEntityBackend record ~ backend, IsPersistBackend backend) => RawSql (Entity record) Source # 
Instance details

Defined in Database.Persist.Sql.Class

Methods

rawSqlCols :: (DBName -> Text) -> Entity record -> (Int, [Text]) Source #

rawSqlColCountReason :: Entity record -> String Source #

rawSqlProcessRow :: [PersistValue] -> Either Text (Entity record) Source #

type Rep (Entity record) Source # 
Instance details

Defined in Database.Persist.Class.PersistEntity

type Rep (Entity record) = D1 ('MetaData "Entity" "Database.Persist.Class.PersistEntity" "persistent-2.10.5.2-LaxG3bjZr5ZKmp9fL1b5Et" 'False) (C1 ('MetaCons "Entity" 'PrefixI 'True) (S1 ('MetaSel ('Just "entityKey") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Key record)) :*: S1 ('MetaSel ('Just "entityVal") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 record)))