beam-0.3.0.0: A type-safe SQL mapper for Haskell that doesn't use Template Haskell

Safe HaskellNone
LanguageHaskell2010

Database.Beam.Query

Synopsis

Documentation

data Q db s a Source

Instances

data TopLevelQ db s a Source

Wrapper for Qs that have been modified in such a way that they can no longer be joined against without the use of subquery. TopLevelQ is also an instance of IsQuery, and so can be passed directly to query or queryList

class IsQuery q Source

Minimal complete definition

toQ

queryToSQL' :: Projectible a => Q db s a -> (a, SQLSelect) Source

all_ :: Database db => DatabaseTable db table -> Q db s (table QExpr) Source

Introduce all entries of a table into the Q monad

join_ :: Database db => DatabaseTable db table -> QExpr Bool -> Q db s (table QExpr) Source

Introduce all entries of a table into the Q monad based on the given SQLExpr

guard_ :: QExpr Bool -> Q db s () Source

Only allow results for which the QExpr yields True

related_ :: (Database db, Table rel) => DatabaseTable db rel -> PrimaryKey rel QExpr -> Q db s (rel QExpr) Source

Introduce all entries of the given table which are referenced by the given ForeignKey

lookup_ :: (Database db, Table rel) => DatabaseTable db rel -> PrimaryKey rel QExpr -> Q db s (rel QExpr) Source

limit_ :: IsQuery q => Integer -> q db s a -> TopLevelQ db s a Source

Limit the number of results returned by a query.

The resulting query is a top-level one that must be passed to query, queryList, or subquery_. See TopLevelQ for details.

offset_ :: IsQuery q => Integer -> q db s a -> TopLevelQ db s a Source

Drop the first offset' results.

The resulting query is a top-level one that must be passed to query, queryList, or subquery_. See TopLevelQ for details.

(==.), (/=.) :: SqlOrd a => a -> a -> QExpr Bool infix 4 Source

div_ :: Integral a => QExpr a -> QExpr a -> QExpr a Source

mod_ :: Integral a => QExpr a -> QExpr a -> QExpr a Source

enum_ :: Show a => a -> QExpr (BeamEnum a) Source

aggregate :: (Projectible a, Aggregating agg) => (a -> agg) -> (forall s. Q db s a) -> Q db s (LiftAggregationsToQExpr agg) Source

orderBy :: (SqlOrderable ordering, IsQuery q) => (a -> ordering) -> q db s a -> TopLevelQ db s a Source

subquery_ :: (IsQuery q, Projectible a, Subqueryable a) => (forall s. q db s a) -> Q db s a Source

beamTxn :: MonadIO m => Beam db m -> (DatabaseSettings db -> BeamT e db m a) -> m (BeamResult e a) Source

insertInto :: (MonadIO m, Functor m, Table table, FromSqlValues (table Identity)) => DatabaseTable db table -> table Identity -> BeamT e db m (table Identity) Source

query :: (IsQuery q, MonadIO m, Functor m, FromSqlValues (QExprToIdentity a), Projectible a) => (forall s. q db s a) -> BeamT e db m (Source (BeamT e db m) (QExprToIdentity a)) Source

queryList :: (IsQuery q, MonadIO m, Functor m, FromSqlValues (QExprToIdentity a), Projectible a) => (forall s. q db s a) -> BeamT e db m [QExprToIdentity a] Source

getOne :: (IsQuery q, MonadIO m, Functor m, FromSqlValues (QExprToIdentity a), Projectible a) => (forall s. q db s a) -> BeamT e db m (Maybe (QExprToIdentity a)) Source

updateWhere :: (MonadIO m, Table tbl) => DatabaseTable db tbl -> (tbl QExpr -> tbl QExpr) -> (tbl QExpr -> QExpr Bool) -> BeamT e db m () Source

saveTo :: (MonadIO m, Table tbl) => DatabaseTable db tbl -> tbl Identity -> BeamT e db m () Source

deleteWhere :: (MonadIO m, Table tbl) => DatabaseTable db tbl -> (tbl QExpr -> QExpr Bool) -> BeamT e db m () Source

deleteFrom :: (MonadIO m, Table tbl) => DatabaseTable db tbl -> PrimaryKey tbl Identity -> BeamT e db m () Source