dbvar-2021.8.23: Mutable variables that are written to disk using delta encodings.
Safe Haskell None
Language Haskell2010

Database.Schema

Synopsis

Synopsis

Typed database tables and rows.

Database columns

toColType :: SqlType -> SqlColType Source #

Helper for converting SqlType into an SQL column type with constraints.

Database rows and tables

data a :. b infixl 3 Source #

Infix notation for a pair of types.

Constructors

a :. b infixl 3

Instances

Instances details
( Eq a, Eq b) => Eq (a :. b) Source #
Instance details

Defined in Database.Schema

( Ord a, Ord b) => Ord (a :. b) Source #
Instance details

Defined in Database.Schema

( Read a, Read b) => Read (a :. b) Source #
Instance details

Defined in Database.Schema

( Show a, Show b) => Show (a :. b) Source #
Instance details

Defined in Database.Schema

( IsRow row, KnownSymbol name, IsCol a) => IsRow (row :. Col name a) Source #
Instance details

Defined in Database.Schema

SQL Queries

data Query row Source #

An SQL query that returns a list of values of type row .

callSql :: ( MonadIO m, IsRow row) => Query row -> SqlPersistT m [row] Source #

Run an SQL query and return a list of rows as result.

runSql :: MonadIO m => Query () -> SqlPersistT m () Source #

Execute an SQL query, but do not return any results

createTable :: IsRow row => Proxy row -> Query () Source #

Create a database table that can store the given rows.

selectAll :: forall row. IsRow row => Query row Source #

Select all rows from the table.

insertOne :: forall row. IsRow row => row -> Query () Source #

Insert a single row into the corresponding table.

repsertOne :: forall row. IsRow row => (row :. Col "id" Primary ) -> Query () Source #

Replace or insert a single row with a primary key into a database.

FIXME: It would be nicer if the "id" column was the first column instead of the last column in the table.

updateOne :: forall row. IsRow row => (row :. Col "id" Primary ) -> Query () Source #

Update one row with a given "id" column in a database table.

deleteAll :: forall row. IsRow row => Proxy row -> Query () Source #

Delete all rows in a database table

deleteOne :: forall row. IsRow row => Proxy row -> Col "id" Primary -> Query () Source #

Delete one row with a given "id" column in a database table.

Testing