seakale-0.2.0.0: Pure SQL layer on top of other libraries

Safe HaskellNone
LanguageHaskell2010

Database.Seakale.Store.Internal

Synopsis

Documentation

data Entity a Source #

A value together with its identifier.

Constructors

Entity 

Fields

Instances

(ToRow backend k (EntityID a), ToRow backend l a, (~) Nat ((:+) k l) i) => ToRow backend i (Entity a) Source # 

Methods

toRow :: backend -> Entity a -> QueryData i Source #

(FromRow backend k (EntityID a), FromRow backend l a, (~) Nat ((:+) k l) i) => FromRow backend i (Entity a) Source # 

Methods

fromRow :: RowParser backend i (Entity a) Source #

(Eq (EntityID a), Eq a) => Eq (Entity a) Source # 

Methods

(==) :: Entity a -> Entity a -> Bool #

(/=) :: Entity a -> Entity a -> Bool #

(Show (EntityID a), Show a) => Show (Entity a) Source # 

Methods

showsPrec :: Int -> Entity a -> ShowS #

show :: Entity a -> String #

showList :: [Entity a] -> ShowS #

eqRelation :: Relation backend k l a -> Relation backend k l a -> Bool Source #

newtype Column Source #

Constructors

Column 

class (Typeable backend, Typeable k, Typeable l, Typeable a) => Storable backend k l a | a -> k, a -> l where Source #

Minimal complete definition

relation

Associated Types

data EntityID a :: * Source #

Methods

relation :: backend -> Relation backend k l a Source #

Instances

(Storable backend k l a, Storable backend i j b, (~) Nat ((:+) k i) g, (~) Nat ((:+) l j) h, Typeable Nat g, Typeable Nat h) => Storable backend g h (FullJoin a b) Source # 

Associated Types

data EntityID (FullJoin a b) :: * Source #

Methods

relation :: backend -> Relation backend g h (FullJoin a b) Source #

(Storable backend k l a, Storable backend i j b, (~) Nat ((:+) k i) g, (~) Nat ((:+) l j) h, Typeable Nat g, Typeable Nat h) => Storable backend g h (InnerJoin a b) Source # 

Associated Types

data EntityID (InnerJoin a b) :: * Source #

Methods

relation :: backend -> Relation backend g h (InnerJoin a b) Source #

(Storable backend k l a, Storable backend i j b, (~) Nat ((:+) k i) g, (~) Nat ((:+) l j) h, Typeable Nat g, Typeable Nat h) => Storable backend g h (RightJoin a b) Source # 

Associated Types

data EntityID (RightJoin a b) :: * Source #

Methods

relation :: backend -> Relation backend g h (RightJoin a b) Source #

(Storable backend k l a, Storable backend i j b, (~) Nat ((:+) k i) g, (~) Nat ((:+) l j) h, Typeable Nat g, Typeable Nat h) => Storable backend g h (LeftJoin a b) Source # 

Associated Types

data EntityID (LeftJoin a b) :: * Source #

Methods

relation :: backend -> Relation backend g h (LeftJoin a b) Source #

data Condition backend a Source #

Constructors

Condition (ByteString -> backend -> (Query n, QueryData n)) 

Instances

Monoid (Condition backend a) Source # 

Methods

mempty :: Condition backend a #

mappend :: Condition backend a -> Condition backend a -> Condition backend a #

mconcat :: [Condition backend a] -> Condition backend a #

eqCondition :: backend -> Condition backend a -> Condition backend a -> Bool Source #

combineConditions :: ByteString -> Condition backend a -> Condition backend a -> Condition backend a Source #

buildCondition :: ByteString -> ByteString -> (backend -> Vector n Column) -> (backend -> QueryData n) -> Condition backend a Source #

buildCondition' :: ByteString -> (backend -> Vector n Column) -> (backend -> Vector n Column) -> Condition backend a Source #

data Order Source #

Constructors

Asc 
Desc 

Instances

Eq Order Source # 

Methods

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

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

Show Order Source # 

Methods

showsPrec :: Int -> Order -> ShowS #

show :: Order -> String #

showList :: [Order] -> ShowS #

data SelectClauses backend a Source #

Constructors

SelectClauses 

Fields

Instances

Monoid (SelectClauses backend a) Source # 

Methods

mempty :: SelectClauses backend a #

mappend :: SelectClauses backend a -> SelectClauses backend a -> SelectClauses backend a #

mconcat :: [SelectClauses backend a] -> SelectClauses backend a #

eqSelectClauses :: backend -> SelectClauses backend a -> SelectClauses backend a -> Bool Source #

buildWhereClause :: Condition backend a -> ByteString -> backend -> ByteString Source #

buildOnClause :: Condition backend a -> ByteString -> backend -> ByteString Source #

buildSelectRequest :: backend -> Relation backend k l a -> Condition backend a -> SelectClauses backend a -> ByteString Source #

buildCountRequest :: backend -> Relation backend k l a -> Condition backend a -> ByteString Source #

data SelectF backend a Source #

Constructors

(Storable backend k l b, FromRow backend (k :+ l) (Entity b)) => Select (Relation backend k l b) (Condition backend b) (SelectClauses backend b) ([Entity b] -> a) 
Storable backend k l b => Count (Relation backend k l b) (Condition backend b) (Integer -> a) 
SelectGetBackend (backend -> a) 
SelectThrowError SeakaleError 
SelectCatchError a (SeakaleError -> a) 

Instances

Monad m => MonadSeakaleBase backend (FreeT (SelectF backend) m) Source # 

Methods

getBackend :: FreeT (SelectF backend) m backend Source #

throwSeakaleError :: SeakaleError -> FreeT (SelectF backend) m a Source #

catchSeakaleError :: FreeT (SelectF backend) m a -> (SeakaleError -> FreeT (SelectF backend) m a) -> FreeT (SelectF backend) m a Source #

Monad m => MonadSelect backend (FreeT (SelectF backend) m) Source # 

Methods

select :: (Storable backend k l a, FromRow backend (k :+ l) (Entity a)) => Relation backend k l a -> Condition backend a -> SelectClauses backend a -> FreeT (SelectF backend) m [Entity a] Source #

count :: Storable backend k l a => Relation backend k l a -> Condition backend a -> FreeT (SelectF backend) m Integer Source #

Functor (SelectF backend) Source # 

Methods

fmap :: (a -> b) -> SelectF backend a -> SelectF backend b #

(<$) :: a -> SelectF backend b -> SelectF backend a #

type SelectT backend = FreeT (SelectF backend) Source #

type Select backend = SelectT backend Identity Source #

class MonadSeakaleBase backend m => MonadSelect backend m where Source #

Minimal complete definition

select, count

Methods

select :: (Storable backend k l a, FromRow backend (k :+ l) (Entity a)) => Relation backend k l a -> Condition backend a -> SelectClauses backend a -> m [Entity a] Source #

count :: Storable backend k l a => Relation backend k l a -> Condition backend a -> m Integer Source #

Instances

(MonadSelect backend m, MonadTrans t, MonadSeakaleBase backend (t m)) => MonadSelect backend (t m) Source # 

Methods

select :: (Storable backend k l a, FromRow backend (k :+ l) (Entity a)) => Relation backend k l a -> Condition backend a -> SelectClauses backend a -> t m [Entity a] Source #

count :: Storable backend k l a => Relation backend k l a -> Condition backend a -> t m Integer Source #

Monad m => MonadSelect backend (RequestT backend m) Source # 

Methods

select :: (Storable backend k l a, FromRow backend (k :+ l) (Entity a)) => Relation backend k l a -> Condition backend a -> SelectClauses backend a -> RequestT backend m [Entity a] Source #

count :: Storable backend k l a => Relation backend k l a -> Condition backend a -> RequestT backend m Integer Source #

Monad m => MonadSelect backend (FreeT (SelectF backend) m) Source # 

Methods

select :: (Storable backend k l a, FromRow backend (k :+ l) (Entity a)) => Relation backend k l a -> Condition backend a -> SelectClauses backend a -> FreeT (SelectF backend) m [Entity a] Source #

count :: Storable backend k l a => Relation backend k l a -> Condition backend a -> FreeT (SelectF backend) m Integer Source #

runSelectT :: Monad m => SelectT backend m a -> RequestT backend m a Source #

runSelect :: Select backend a -> Request backend a Source #

data UpdateSetter backend a Source #

Constructors

UpdateSetter (backend -> Vector n (Column, ByteString)) 

Instances

Monoid (UpdateSetter backend a) Source # 

Methods

mempty :: UpdateSetter backend a #

mappend :: UpdateSetter backend a -> UpdateSetter backend a -> UpdateSetter backend a #

mconcat :: [UpdateSetter backend a] -> UpdateSetter backend a #

eqUpdateSetter :: backend -> UpdateSetter backend a -> UpdateSetter backend a -> Bool Source #

data StoreF backend a Source #

Constructors

(Storable backend k l b, ToRow backend l b, FromRow backend k (EntityID b)) => Insert [b] ([EntityID b] -> a) 
Storable backend k l b => Update (UpdateSetter backend b) (Condition backend b) (Integer -> a) 
Storable backend k l b => Delete (Condition backend b) (Integer -> a) 

Instances

MonadSeakaleBase backend m => MonadSeakaleBase backend (FreeT (StoreF backend) m) Source # 

Methods

getBackend :: FreeT (StoreF backend) m backend Source #

throwSeakaleError :: SeakaleError -> FreeT (StoreF backend) m a Source #

catchSeakaleError :: FreeT (StoreF backend) m a -> (SeakaleError -> FreeT (StoreF backend) m a) -> FreeT (StoreF backend) m a Source #

MonadSelect backend m => MonadStore backend (FreeT (StoreF backend) m) Source # 

Methods

insert :: (Storable backend k l b, ToRow backend l b, FromRow backend k (EntityID b)) => [b] -> FreeT (StoreF backend) m [EntityID b] Source #

update :: Storable backend k l a => UpdateSetter backend a -> Condition backend a -> FreeT (StoreF backend) m Integer Source #

delete :: Storable backend k l a => Condition backend a -> FreeT (StoreF backend) m Integer Source #

Functor (StoreF backend) Source # 

Methods

fmap :: (a -> b) -> StoreF backend a -> StoreF backend b #

(<$) :: a -> StoreF backend b -> StoreF backend a #

type StoreT backend m = FreeT (StoreF backend) (SelectT backend m) Source #

type Store backend = StoreT backend Identity Source #

class MonadSelect backend m => MonadStore backend m where Source #

Minimal complete definition

insert, update, delete

Methods

insert :: (Storable backend k l b, ToRow backend l b, FromRow backend k (EntityID b)) => [b] -> m [EntityID b] Source #

update :: Storable backend k l a => UpdateSetter backend a -> Condition backend a -> m Integer Source #

delete :: Storable backend k l a => Condition backend a -> m Integer Source #

Instances

(MonadStore backend m, MonadTrans t, MonadSeakaleBase backend (t m)) => MonadStore backend (t m) Source # 

Methods

insert :: (Storable backend k l b, ToRow backend l b, FromRow backend k (EntityID b)) => [b] -> t m [EntityID b] Source #

update :: Storable backend k l a => UpdateSetter backend a -> Condition backend a -> t m Integer Source #

delete :: Storable backend k l a => Condition backend a -> t m Integer Source #

Monad m => MonadStore backend (RequestT backend m) Source # 

Methods

insert :: (Storable backend k l b, ToRow backend l b, FromRow backend k (EntityID b)) => [b] -> RequestT backend m [EntityID b] Source #

update :: Storable backend k l a => UpdateSetter backend a -> Condition backend a -> RequestT backend m Integer Source #

delete :: Storable backend k l a => Condition backend a -> RequestT backend m Integer Source #

MonadSelect backend m => MonadStore backend (FreeT (StoreF backend) m) Source # 

Methods

insert :: (Storable backend k l b, ToRow backend l b, FromRow backend k (EntityID b)) => [b] -> FreeT (StoreF backend) m [EntityID b] Source #

update :: Storable backend k l a => UpdateSetter backend a -> Condition backend a -> FreeT (StoreF backend) m Integer Source #

delete :: Storable backend k l a => Condition backend a -> FreeT (StoreF backend) m Integer Source #

buildSetter :: backend -> UpdateSetter backend a -> ByteString Source #

buildUpdateRequest :: backend -> Relation backend k l a -> UpdateSetter backend a -> Condition backend a -> ByteString Source #

buildDeleteRequest :: backend -> Relation backend k l a -> Condition backend a -> ByteString Source #

runStoreT :: forall backend m a. Monad m => StoreT backend m a -> RequestT backend m a Source #

runStore :: Store backend a -> Request backend a Source #