ihp-1.4.0: Haskell Web Framework
Safe HaskellNone
LanguageGHC2021

IHP.ModelSupport

Synopsis

Documentation

class KnownSymbol (GetTableName record) => Table record where Source #

Access meta data for a database table

Minimal complete definition

columnNames, primaryKeyColumnNames

Methods

tableName :: Text Source #

Returns the table name of a given model.

Example:

>>> tableName @User
"users"

columnNames :: [Text] Source #

Returns the list of column names for a given model

Example:

>>> columnNames @User
["id", "email", "created_at"]

primaryKeyColumnNames :: [Text] Source #

Returns the list of column names, that are contained in the primary key for a given model

Example:

>>> primaryKeyColumnNames @User
["id"]
>>> primaryKeyColumnNames @PostTagging
["post_id", "tag_id"]

isValid :: HasField "meta" record MetaBag => record -> Bool Source #

Returns True when a record has no validation errors attached from a previous validation call

Example:

isValidProject :: Project -> Bool
isValidProject project =
    project
    |> validateField #name isNonEmpty
    |> isValid

ids :: HasField "id" record id => [record] -> [id] Source #

Returns the ids for a list of models

Shorthand for map (.id) records.

>>> users <- query @User |> fetch
>>> ids users
[227fbba3-0578-4eb8-807d-b9b692c3644f, 9d7874f2-5343-429b-bcc4-8ee62a5a6895, ...] :: [Id User]

commitTransaction :: (?modelContext :: ModelContext) => IO () Source #

class Record model where Source #

Methods

newRecord :: model Source #

withTransaction :: (?modelContext :: ModelContext) => ((?modelContext :: ModelContext) => IO a) -> IO a Source #

Executes the given block with a database transaction

Example:

withTransaction do
   company <- newRecord @Company |> createRecord

   -- When creating the user fails, there will be no company left over
   user <- newRecord @User
       |> set #companyId company.id
       |> createRecord

   company <- company
       |> set #ownerId user.id
       |> updateRecord

didTouchField :: forall (fieldName :: Symbol) fieldValue record. (KnownSymbol fieldName, HasField fieldName record fieldValue, HasField "meta" record MetaBag, Eq fieldValue, Typeable record) => Proxy fieldName -> record -> Bool Source #

Returns True if set was called on that field

Example: Returns False for freshly fetched records

>>> let projectId = "227fbba3-0578-4eb8-807d-b9b692c3644f" :: Id Project
>>> project <- fetch projectId
>>> didTouchField #name project
False

Example: Returns True after setting a field

>>> let projectId = "227fbba3-0578-4eb8-807d-b9b692c3644f" :: Id Project
>>> project <- fetch projectId
>>> project |> set #name project.name |> didTouchField #name
True

getModelName :: KnownSymbol (GetModelName model) => Text Source #

Returns the model name of a given model as Text

Example:

>>> modelName @User
"User"
>>> modelName @Project
"Project"

isNew :: HasField "meta" model MetaBag => model -> Bool Source #

Returns True when the record has not been saved to the database yet. Returns False otherwise.

Example: Returns True when a record has not been inserted yet.

>>> let project = newRecord @Project
>>> isNew project
True

Example: Returns False after inserting a record.

>>> project <- createRecord project
>>> isNew project
False

Example: Returns False for records which have been fetched from the database.

>>> book <- query @Book |> fetchOne
>>> isNew book
False

notConnectedModelContext :: Logger -> ModelContext Source #

Provides a mock ModelContext to be used when a database connection is not available

withModelContext :: ByteString -> Logger -> (ModelContext -> IO a) -> IO a Source #

Bracket-style wrapper around createModelContext that ensures the database pool is released when the callback completes (or throws an exception).

createRecord :: (?modelContext :: ModelContext, CanCreate model) => model -> IO model Source #

deleteRecord :: forall record (table :: Symbol). (?modelContext :: ModelContext, Table record, Show (PrimaryKey table), HasField "id" record (Id record), GetTableName record ~ table, record ~ GetModelByTableName table, DefaultParamEncoder (Id' table)) => record -> IO () Source #

Runs a DELETE query for a record.

>>> let project :: Project = ...
>>> deleteRecord project
DELETE FROM projects WHERE id = '..'

Use deleteRecords if you want to delete multiple records.

sqlQuery :: (?modelContext :: ModelContext, ToSnippetParams q, FromRowHasql r) => Query -> q -> IO [r] Source #

Runs a raw sql query

Example:

users <- sqlQuery "SELECT id, firstname, lastname FROM users" ()

Take a look at IHP.QueryBuilder for a typesafe approach on building simple queries.

  • AutoRefresh:* When using sqlQuery with AutoRefresh, you need to use trackTableRead to let AutoRefresh know that you have accessed a certain table. Otherwise AutoRefresh will not watch table of your custom sql query.

Use sqlQuerySingleRow if you expect only a single row to be returned.

sqlQueryScalar :: (?modelContext :: ModelContext, ToSnippetParams q, HasqlDecodeColumn value) => Query -> q -> IO value Source #

Runs a raw sql query which results in a single scalar value such as an integer or string

Example:

usersCount <- sqlQueryScalar "SELECT COUNT(*) FROM users"

Take a look at IHP.QueryBuilder for a typesafe approach on building simple queries.

didChange :: forall (fieldName :: Symbol) fieldValue record. (KnownSymbol fieldName, HasField fieldName record fieldValue, HasField "meta" record MetaBag, Eq fieldValue, Typeable record) => Proxy fieldName -> record -> Bool Source #

Returns True if the specific field of the record has unsaved changes

Example: Returns False for freshly fetched records

>>> let projectId = "227fbba3-0578-4eb8-807d-b9b692c3644f" :: Id Project
>>> project <- fetch projectId
>>> didChange #name project
False

Example: Returns True after setting a field

>>> let projectId = "227fbba3-0578-4eb8-807d-b9b692c3644f" :: Id Project
>>> project <- fetch projectId
>>> project |> set #name "New Name" |> didChange #name
True

Example: Setting a flash message after updating the profile picture

when (user |> didChange #profilePictureUrl) (setSuccessMessage "Your Profile Picture has been updated. It might take a few minutes until it shows up everywhere")

unpackId :: forall (model :: Symbol). Id' model -> PrimaryKey model Source #

Unwraps a Id value into an UUID

>>> unpackId ("296e5a50-b237-4ee9-83b0-17fb1e6f208f" :: Id User)
"296e5a50-b237-4ee9-83b0-17fb1e6f208f" :: UUID

recordToInputValue :: (HasField "id" entity (Id entity), Show (PrimaryKey (GetTableName entity))) => entity -> Text Source #

packId :: forall (model :: Symbol). PrimaryKey model -> Id' model Source #

Turns an UUID into a Id type

let uuid :: UUID = "5240e79c-97ff-4a5f-8567-84112541aaba"
let userId :: Id User = packId uuid

textToId :: forall (model :: Symbol) text. (HasCallStack, ParsePrimaryKey (PrimaryKey model), ConvertibleStrings text Text) => text -> Id' model Source #

Transforms a text, bytestring or string into an Id. Throws an exception if the input is invalid.

Example:

let projectIdText = "7cbc76e2-1c4f-49b6-a7d9-5015e7575a9b" :: Text
let projectId = (textToId projectIdText) :: Id Project

In case your UUID value is hardcoded, there is also an IsString instance, so you can just write it like:

let projectId = "ca63aace-af4b-4e6c-bcfa-76ca061dbdc6" :: Id Project

sqlQueryHasql :: (?modelContext :: ModelContext) => Pool -> Snippet -> Result a -> IO a Source #

Runs a query using the hasql pool with prepared statements

This function executes a query using hasql's prepared statement mechanism, which provides better performance than postgresql-simple for repeated queries.

When RLS is enabled, the query is wrapped in a transaction that first sets the role and user id via setRLSConfigStatement.

Example:

users <- sqlQueryHasql pool snippet (Decoders.rowList userDecoder)

sqlQuerySingleRow :: (?modelContext :: ModelContext, ToSnippetParams query, FromRowHasql record) => Query -> query -> IO record Source #

Runs a raw sql query, that is expected to return a single result row

Like sqlQuery, but useful when you expect only a single row as the result

Example:

user <- sqlQuerySingleRow "SELECT id, firstname, lastname FROM users WHERE id = ?" (Only user.id)

Take a look at IHP.QueryBuilder for a typesafe approach on building simple queries.

  • AutoRefresh:* When using sqlQuerySingleRow with AutoRefresh, you need to use trackTableRead to let AutoRefresh know that you have accessed a certain table. Otherwise AutoRefresh will not watch table of your custom sql query.

sqlExec :: (?modelContext :: ModelContext, ToSnippetParams q) => Query -> q -> IO Int64 Source #

Runs a sql statement (like a CREATE statement)

Example:

sqlExec "CREATE TABLE users ()" ()

sqlExecHasqlCount :: (?modelContext :: ModelContext) => Pool -> Snippet -> IO Int64 Source #

Like sqlExecHasql but returns the number of affected rows

When RLS is enabled, the statement is wrapped in a transaction that first sets the role and user id via setRLSConfigStatement.

sqlExecDiscardResult :: (?modelContext :: ModelContext, ToSnippetParams q) => Query -> q -> IO () Source #

Runs a sql statement (like a CREATE statement), but doesn't return any result

Example:

sqlExecDiscardResult "CREATE TABLE users ()" ()

setRLSConfigStatement :: Statement (Text, Text) () Source #

Prepared statement that sets the RLS role and user id using set_config().

Uses set_config(setting, value, is_local) which is a regular SQL function that supports parameterized values in the extended query protocol, unlike SET LOCAL which is a utility command that cannot be parameterized.

The third argument true makes the setting local to the current transaction, equivalent to SET LOCAL.

isCachedPlanError :: UsageError -> Bool Source #

Detects errors caused by stale schema after make db recreates the database.

Matches four categories:

  1. PostgreSQL "cached plan must not change result type" (error code 0A000) — the server rejects a prepared statement whose result columns changed.
  2. PostgreSQL "cache lookup failed for type" (error code XX000) — a prepared statement references a type OID that no longer exists after schema recreation (types get new OIDs).
  3. Hasql MissingTypesSessionError — custom enum types (e.g. JOB_STATUS) get new OIDs after schema recreation, and hasql's type registry can't find them.
  4. Hasql UnexpectedColumnTypeStatementError — the column's type OID no longer matches the OID cached in the prepared statement / decoder.

data HasqlError Source #

Exception type for hasql errors

Constructors

HasqlError UsageError 

sqlExecHasql :: (?modelContext :: ModelContext) => Pool -> Snippet -> IO () Source #

Like sqlQueryHasql but for statements that don't return results (DELETE, etc.)

When RLS is enabled, the statement is wrapped in a transaction that first sets the role and user id via setRLSConfigStatement.

runSessionHasql :: (?modelContext :: ModelContext) => Pool -> Session () -> IO () Source #

Like sqlExecHasql but for raw Session values (e.g. multi-statement DDL via sql)

Use this instead of sqlExecHasql when you need the simple protocol (no prepared statements), e.g. for multi-statement SQL like trigger creation.

Example:

runSessionHasql pool (Hasql.sql "BEGIN; CREATE ...; COMMIT;")

data SessionRequest where Source #

Existential wrapper for sub-session requests in a transaction

Constructors

SessionRequest :: forall a. Session a -> MVar (Either SessionError a) -> SessionRequest 

processRequests :: MVar (Maybe SessionRequest) -> Session () Source #

Loop that reads sub-session requests from an MVar and executes them on the current transaction's connection. Stops when it receives Nothing.

sqlQueryScalarOrNothing :: (?modelContext :: ModelContext, ToSnippetParams q, HasqlDecodeColumn value) => Query -> q -> IO (Maybe value) Source #

Runs a raw sql query which results in a single scalar value such as an integer or string, or nothing

Example:

usersCount <- sqlQueryScalarOrNothing "SELECT COUNT(*) FROM users"

Take a look at IHP.QueryBuilder for a typesafe approach on building simple queries.

withRowLevelSecurityDisabled :: (?modelContext :: ModelContext) => ((?modelContext :: ModelContext) => IO a) -> IO a Source #

Executes the given block with the main database role and temporarly sidesteps the row level security policies.

This is used e.g. by IHP AutoRefresh to be able to set up it's database triggers. When trying to set up a database trigger from the ihp_authenticated role, it typically fails because it's missing permissions. Using withRowLevelSecurityDisabled we switch to the main role which is allowed to set up database triggers.

SQL queries run from within the passed block are executed in their own transaction.

Example:

-- SQL code executed here might be run from the ihp_authenticated role
withRowLevelSecurityDisabled do
   -- SQL code executed here is run as the main IHP db role
   sqlExec "CREATE OR REPLACE FUNCTION .." ()

rollbackTransaction :: (?modelContext :: ModelContext) => IO () Source #

primaryKeyConditionColumnSelector :: Table record => Text Source #

Returns ByteString, that represents the part of an SQL where clause, that matches on a tuple consisting of all the primary keys For table with simple primary keys this simply returns the name of the primary key column, without wrapping in a tuple >>> primaryKeyColumnSelector PostTag "(post_tags.post_id, post_tags.tag_id)" >>> primaryKeyColumnSelector Post "post_tags.post_id"

deleteRecordById :: forall record (table :: Symbol). (?modelContext :: ModelContext, Table record, Show (PrimaryKey table), GetTableName record ~ table, record ~ GetModelByTableName table, DefaultParamEncoder (Id' table)) => Id' table -> IO () Source #

Like deleteRecord but using an Id

>>> let project :: Id Project = ...
>>> delete projectId
DELETE FROM projects WHERE id = '..'

deleteRecords :: forall record (table :: Symbol). (?modelContext :: ModelContext, Show (PrimaryKey table), Table record, HasField "id" record (Id' table), GetTableName record ~ table, record ~ GetModelByTableName table, DefaultParamEncoder [Id' table]) => [record] -> IO () Source #

Runs a DELETE query for a list of records.

>>> let projects :: [Project] = ...
>>> deleteRecords projects
DELETE FROM projects WHERE id IN (..)

deleteRecordByIds :: forall record (table :: Symbol). (?modelContext :: ModelContext, Show (PrimaryKey table), Table record, GetTableName record ~ table, record ~ GetModelByTableName table, DefaultParamEncoder [Id' table]) => [Id' table] -> IO () Source #

Like deleteRecordById but for a list of Ids.

>>> let projectIds :: [ Id Project ] = ...
>>> delete projectIds
DELETE FROM projects WHERE id IN ('..')

deleteAll :: (?modelContext :: ModelContext, Table record) => IO () Source #

Runs a DELETE query to delete all rows in a table.

>>> deleteAll @Project
DELETE FROM projects

didChangeRecord :: HasField "meta" record MetaBag => record -> Bool Source #

Returns True if any fields of the record have unsaved changes

Example: Returns False for freshly fetched records

>>> let projectId = "227fbba3-0578-4eb8-807d-b9b692c3644f" :: Id Project
>>> project <- fetch projectId
>>> didChangeRecord project
False

Example: Returns True after setting a field

>>> let projectId = "227fbba3-0578-4eb8-807d-b9b692c3644f" :: Id Project
>>> project <- fetch projectId
>>> project |> set #name "New Name" |> didChangeRecord
True

fieldWithDefault :: forall (name :: Symbol) model value. (KnownSymbol name, HasField name model value, HasField "meta" model MetaBag) => Proxy name -> model -> FieldWithDefault value Source #

Construct a FieldWithDefault

Use the default SQL value when the field hasn't been touched since the record was created. This information is stored in the touchedFields attribute of the meta field.

fieldWithUpdate :: forall (name :: Symbol) model value. (KnownSymbol name, HasField name model value, HasField "meta" model MetaBag) => Proxy name -> model -> FieldWithUpdate name value Source #

Construct a FieldWithUpdate

Use the current database value when the field hasn't been touched since the record was accessed. This information is stored in the touchedFields attribute of the meta field.

fieldWithDefaultSnippet :: forall (name :: Symbol) model value. (KnownSymbol name, HasField name model value, HasField "meta" model MetaBag, DefaultParamEncoder value) => Proxy name -> model -> Snippet Source #

Like fieldWithDefault but produces a hasql Snippet instead of a FieldWithDefault

When the field hasn't been touched, produces DEFAULT. Otherwise encodes the value using hasql's DefaultParamEncoder.

fieldWithUpdateSnippet :: forall (name :: Symbol) model value. (KnownSymbol name, HasField name model value, HasField "meta" model MetaBag, DefaultParamEncoder value) => Proxy name -> model -> Snippet Source #

Like fieldWithUpdate but produces a hasql Snippet instead of a FieldWithUpdate

When the field hasn't been touched, produces the column name (keeping the current DB value). Otherwise encodes the new value using hasql's DefaultParamEncoder.

trackTableRead :: (?modelContext :: ModelContext) => Text -> IO () Source #

Useful to manually mark a table read when doing a custom sql query inside AutoRefresh or withTableReadTracker.

When using fetch on a query builder, this function is automatically called. That's why you only need to call it yourself when using sqlQuery to run a custom query.

Example:

action MyAction = autoRefresh do
    users <- sqlQuery "SELECT * FROM users WHERE .."
    trackTableRead "users"

    render MyView { .. }

withTableReadTracker :: (?modelContext :: ModelContext) => ((?modelContext :: ModelContext, ?touchedTables :: IORef (Set Text)) => IO ()) -> IO () Source #

Track all tables in SELECT queries executed within the given IO action.

You can read the touched tables by this function by accessing the variable ?touchedTables inside your given IO action.

Example:

withTableReadTracker do
    project <- query @Project |> fetchOne
    user <- query @User |> fetchOne

    tables <- readIORef ?touchedTables
    -- tables = Set.fromList ["projects", "users"]

onlyWhere :: forall record (fieldName :: Symbol) value. (KnownSymbol fieldName, HasField fieldName record value, Eq value) => Proxy fieldName -> value -> [record] -> [record] Source #

Shorthand filter function

In IHP code bases you often write filter functions such as these:

getUserPosts user posts =
    filter (\p -> p.userId == user.id) posts

This can be written in a shorter way using onlyWhere:

getUserPosts user posts =
    posts |> onlyWhere #userId user.id

Because the userId field is an Id, we can use onlyWhereReferences to make it even shorter:

getUserPosts user posts =
    posts |> onlyWhereReferences #userId user

If the Id field is nullable, we need to use onlyWhereReferencesMaybe:

getUserTasks user tasks =
    tasks |> onlyWhereReferencesMaybe #optionalUserId user

onlyWhereReferences :: forall record (fieldName :: Symbol) value referencedRecord. (KnownSymbol fieldName, HasField fieldName record value, Eq value, HasField "id" referencedRecord value) => Proxy fieldName -> referencedRecord -> [record] -> [record] Source #

Shorthand filter function for Id fields

In IHP code bases you often write filter functions such as these:

getUserPosts user posts =
    filter (\p -> p.userId == user.id) posts

This can be written in a shorter way using onlyWhereReferences:

getUserPosts user posts =
    posts |> onlyWhereReferences #userId user

If the Id field is nullable, we need to use onlyWhereReferencesMaybe:

getUserTasks user tasks =
    tasks |> onlyWhereReferencesMaybe #optionalUserId user

See onlyWhere for more details.

onlyWhereReferencesMaybe :: forall record (fieldName :: Symbol) value referencedRecord. (KnownSymbol fieldName, HasField fieldName record (Maybe value), Eq value, HasField "id" referencedRecord value) => Proxy fieldName -> referencedRecord -> [record] -> [record] Source #

Shorthand filter function for nullable Id fields

In IHP code bases you often write filter functions such as these:

getUserTasks user tasks =
    filter (\task -> task.optionalUserId == Just user.id) tasks

This can be written in a shorter way using onlyWhereReferencesMaybe:

getUserTasks user tasks =
    tasks |> onlyWhereReferencesMaybe #optionalUserId user

See onlyWhere for more details.

copyRecord :: (Table record, SetField "id" record id, Default id, SetField "meta" record MetaBag) => record -> record Source #

Copies all the fields (except the id field) into a new record

Example: Duplicate a database record (except the primary key of course)

project <- fetch projectId
duplicatedProject <- createRecord (copyRecord project)

withoutQueryLogging :: (?modelContext :: ModelContext) => ((?modelContext :: ModelContext) => result) -> result Source #

Runs sql queries without logging them

Example:

users <- withoutQueryLogging (sqlQuery "SELECT * FROM users" ())

data Point #

Constructors

Point Double Double 

Instances

Instances details
Arbitrary Point 
Instance details

Defined in PostgresqlTypes.Point

Default Point Source # 
Instance details

Defined in IHP.ModelSupport

Methods

def :: Point Source #

IsString Point 
Instance details

Defined in PostgresqlTypes.Point

Methods

fromString :: String -> Point #

Read Point 
Instance details

Defined in PostgresqlTypes.Point

Show Point 
Instance details

Defined in PostgresqlTypes.Point

Methods

showsPrec :: Int -> Point -> ShowS #

show :: Point -> String #

showList :: [Point] -> ShowS #

Eq Point 
Instance details

Defined in PostgresqlTypes.Point

Methods

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

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

Ord Point 
Instance details

Defined in PostgresqlTypes.Point

Methods

compare :: Point -> Point -> Ordering #

(<) :: Point -> Point -> Bool #

(<=) :: Point -> Point -> Bool #

(>) :: Point -> Point -> Bool #

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

max :: Point -> Point -> Point #

min :: Point -> Point -> Point #

Hashable Point 
Instance details

Defined in PostgresqlTypes.Point

DefaultParamEncoder Point Source #

Encode Point as PostgreSQL point via postgresql-types binary encoder

Instance details

Defined in IHP.Hasql.Encoders

IsScalar Point 
Instance details

Defined in Hasql.PostgresqlTypes

IsScalar Point 
Instance details

Defined in PostgresqlTypes.Point

ParamReader Point Source # 
Instance details

Defined in IHP.Controller.Param

DefaultParamEncoder (Maybe Point) Source #

Encode 'Maybe Point' as nullable PostgreSQL point

Instance details

Defined in IHP.Hasql.Encoders

data Polygon #

Instances

Instances details
Arbitrary Polygon 
Instance details

Defined in PostgresqlTypes.Polygon

Default Polygon Source # 
Instance details

Defined in IHP.ModelSupport

Methods

def :: Polygon Source #

IsString Polygon 
Instance details

Defined in PostgresqlTypes.Polygon

Methods

fromString :: String -> Polygon #

Read Polygon 
Instance details

Defined in PostgresqlTypes.Polygon

Show Polygon 
Instance details

Defined in PostgresqlTypes.Polygon

Eq Polygon 
Instance details

Defined in PostgresqlTypes.Polygon

Methods

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

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

Ord Polygon 
Instance details

Defined in PostgresqlTypes.Polygon

Hashable Polygon 
Instance details

Defined in PostgresqlTypes.Polygon

DefaultParamEncoder Polygon Source #

Encode Polygon as PostgreSQL polygon via postgresql-types binary encoder

Instance details

Defined in IHP.Hasql.Encoders

IsScalar Polygon 
Instance details

Defined in Hasql.PostgresqlTypes

IsScalar Polygon 
Instance details

Defined in PostgresqlTypes.Polygon

ParamReader Polygon Source # 
Instance details

Defined in IHP.Controller.Param

DefaultParamEncoder (Maybe Polygon) Source #

Encode 'Maybe Polygon' as nullable PostgreSQL polygon

Instance details

Defined in IHP.Hasql.Encoders

fold :: (Word32 -> Word8 -> a) -> (Word32 -> Word32 -> Word32 -> Word32 -> Word8 -> a) -> Inet -> a #

data Inet #

Instances

Instances details
Arbitrary Inet 
Instance details

Defined in PostgresqlTypes.Inet

Default Inet Source # 
Instance details

Defined in IHP.ModelSupport

Methods

def :: Inet Source #

IsString Inet 
Instance details

Defined in PostgresqlTypes.Inet

Methods

fromString :: String -> Inet #

Read Inet 
Instance details

Defined in PostgresqlTypes.Inet

Show Inet 
Instance details

Defined in PostgresqlTypes.Inet

Methods

showsPrec :: Int -> Inet -> ShowS #

show :: Inet -> String #

showList :: [Inet] -> ShowS #

Eq Inet 
Instance details

Defined in PostgresqlTypes.Inet

Methods

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

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

Ord Inet 
Instance details

Defined in PostgresqlTypes.Inet

Methods

compare :: Inet -> Inet -> Ordering #

(<) :: Inet -> Inet -> Bool #

(<=) :: Inet -> Inet -> Bool #

(>) :: Inet -> Inet -> Bool #

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

max :: Inet -> Inet -> Inet #

min :: Inet -> Inet -> Inet #

Hashable Inet 
Instance details

Defined in PostgresqlTypes.Inet

DefaultParamEncoder Inet Source #

Encode Inet as PostgreSQL inet via postgresql-types binary encoder

Instance details

Defined in IHP.Hasql.Encoders

IsScalar Inet 
Instance details

Defined in Hasql.PostgresqlTypes

InputValue Inet Source # 
Instance details

Defined in IHP.InputValue

Methods

inputValue :: Inet -> Text Source #

IsScalar Inet 
Instance details

Defined in PostgresqlTypes.Inet

ParamReader Inet Source # 
Instance details

Defined in IHP.Controller.Param

DefaultParamEncoder (Maybe Inet) Source #

Encode 'Maybe Inet' as nullable PostgreSQL inet

Instance details

Defined in IHP.Hasql.Encoders

data Weight #

Constructors

AWeight 
BWeight 
CWeight 
DWeight 

Instances

Instances details
Arbitrary Weight 
Instance details

Defined in PostgresqlTypes.Tsvector

Bounded Weight 
Instance details

Defined in PostgresqlTypes.Tsvector

Enum Weight 
Instance details

Defined in PostgresqlTypes.Tsvector

Read Weight 
Instance details

Defined in PostgresqlTypes.Tsvector

Show Weight 
Instance details

Defined in PostgresqlTypes.Tsvector

Eq Weight 
Instance details

Defined in PostgresqlTypes.Tsvector

Methods

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

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

Ord Weight 
Instance details

Defined in PostgresqlTypes.Tsvector

Hashable Weight 
Instance details

Defined in PostgresqlTypes.Tsvector

data Tsvector #

Instances

Instances details
Arbitrary Tsvector 
Instance details

Defined in PostgresqlTypes.Tsvector

Default Tsvector Source # 
Instance details

Defined in IHP.ModelSupport

Methods

def :: Tsvector Source #

IsString Tsvector 
Instance details

Defined in PostgresqlTypes.Tsvector

Read Tsvector 
Instance details

Defined in PostgresqlTypes.Tsvector

Show Tsvector 
Instance details

Defined in PostgresqlTypes.Tsvector

Eq Tsvector 
Instance details

Defined in PostgresqlTypes.Tsvector

Ord Tsvector 
Instance details

Defined in PostgresqlTypes.Tsvector

Hashable Tsvector 
Instance details

Defined in PostgresqlTypes.Tsvector

DefaultParamEncoder Tsvector Source #

Encode Tsvector as PostgreSQL tsvector via postgresql-types binary encoder

Instance details

Defined in IHP.Hasql.Encoders

IsScalar Tsvector 
Instance details

Defined in Hasql.PostgresqlTypes

IsScalar Tsvector 
Instance details

Defined in PostgresqlTypes.Tsvector

DefaultParamEncoder (Maybe Tsvector) Source #

Encode 'Maybe Tsvector' as nullable PostgreSQL tsvector

Instance details

Defined in IHP.Hasql.Encoders

data Interval #

Instances

Instances details
Arbitrary Interval 
Instance details

Defined in PostgresqlTypes.Interval

Default Interval Source # 
Instance details

Defined in IHP.ModelSupport

Methods

def :: Interval Source #

IsString Interval 
Instance details

Defined in PostgresqlTypes.Interval

Bounded Interval 
Instance details

Defined in PostgresqlTypes.Interval

Read Interval 
Instance details

Defined in PostgresqlTypes.Interval

Show Interval 
Instance details

Defined in PostgresqlTypes.Interval

Eq Interval 
Instance details

Defined in PostgresqlTypes.Interval

Ord Interval 
Instance details

Defined in PostgresqlTypes.Interval

Hashable Interval 
Instance details

Defined in PostgresqlTypes.Interval

DefaultParamEncoder Interval Source #

Encode Interval as PostgreSQL interval via postgresql-types binary encoder

Instance details

Defined in IHP.Hasql.Encoders

IsScalar Interval 
Instance details

Defined in Hasql.PostgresqlTypes

InputValue Interval Source # 
Instance details

Defined in IHP.InputValue

IsScalar Interval 
Instance details

Defined in PostgresqlTypes.Interval

ParamReader Interval Source # 
Instance details

Defined in IHP.Controller.Param

DefaultParamEncoder (Maybe Interval) Source #

Encode 'Maybe Interval' as nullable PostgreSQL interval

Instance details

Defined in IHP.Hasql.Encoders

Orphan instances

Default Value Source # 
Instance details

Methods

def :: Value Source #

Default MetaBag Source # 
Instance details

Methods

def :: MetaBag Source #

Default Inet Source # 
Instance details

Methods

def :: Inet Source #

Default Interval Source # 
Instance details

Methods

def :: Interval Source #

Default Point Source # 
Instance details

Methods

def :: Point Source #

Default Polygon Source # 
Instance details

Methods

def :: Polygon Source #

Default Tsvector Source # 
Instance details

Methods

def :: Tsvector Source #

Default Scientific Source # 
Instance details

Default Text Source # 
Instance details

Methods

def :: Text Source #

Default Day Source # 
Instance details

Methods

def :: Day Source #

Default NominalDiffTime Source # 
Instance details

Default UTCTime Source # 
Instance details

Methods

def :: UTCTime Source #

Default LocalTime Source # 
Instance details

Methods

def :: LocalTime Source #

Default TimeOfDay Source # 
Instance details

Methods

def :: TimeOfDay Source #

ParsePrimaryKey Text Source # 
Instance details

ParsePrimaryKey UUID Source # 
Instance details

SetField "annotations" MetaBag [(Text, Violation)] Source # 
Instance details

SetField "touchedFields" MetaBag [Text] Source # 
Instance details

Methods

setField :: [Text] -> MetaBag -> MetaBag Source #

FromJSON (PrimaryKey a) => FromJSON (Id' a) Source # 
Instance details

ToJSON (PrimaryKey a) => ToJSON (Id' a) Source # 
Instance details

Default (Binary ByteString) Source # 
Instance details

(Read (PrimaryKey model), ParsePrimaryKey (PrimaryKey model)) => IsString (Id' model) Source #

Sometimes you have a hardcoded UUID value which represents some record id. This instance allows you to write the Id like a string:

let projectId = "ca63aace-af4b-4e6c-bcfa-76ca061dbdc6" :: Id Project
Instance details

Methods

fromString :: String -> Id' model #

Show (PrimaryKey model) => Show (Id' model) Source # 
Instance details

Methods

showsPrec :: Int -> Id' model -> ShowS #

show :: Id' model -> String #

showList :: [Id' model] -> ShowS #

IsEmpty (PrimaryKey table) => IsEmpty (Id' table) Source # 
Instance details

Methods

isEmpty :: Id' table -> Bool Source #

InputValue (PrimaryKey model') => InputValue (Id' model') Source # 
Instance details

Methods

inputValue :: Id' model' -> Text Source #