File tree Expand file tree Collapse file tree
database-generic/src/Database/Generic/Entity Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,12 +5,12 @@ Database-agnostic interface to generically persisted data.
55## Introduction
66
77Explanation of the above:
8- - Database-agnostic interface : the typeclass is called ` MonadDb ` , and you must
9- specify how it can communicate with your database (we provide an example for
10- connecting to a PostgreSQL server ).
11- - Generically persisted data: you can derive the necessary instances for your
12- data types via ` Generics ` . This will enable ` MonadDb ` to read/write instances
13- of your data types to/from your database.
8+ - Database-agnostic: the typeclass is called ` MonadDb ` , and you must specify how
9+ an instance can communicate with your database. We provide an example for
10+ connecting to PostgreSQL in the [ tutorial ] ( tutorial/tutorial/main.hs ) .
11+ - Generically persisted data: you can derive the necessary instances in one line
12+ via ` Generics ` , to enable ` MonadDb ` to read/write instances of your data types
13+ to/from your database.
1414
1515A key intended feature of this library is that the typeclass ` MonadDb ` can be
1616used either server-side or client-side. Allowing your client application (e.g.
@@ -23,7 +23,8 @@ to your database without having to write the usual server boilerplate.
2323
2424## Quick Start
2525
26- A tutorial as code exists [ here] ( tutorial/tutorial/Main.hs ) .
26+ The [ tutorial as code] ( tutorial/tutorial/Main.hs ) is the recommended way of
27+ becoming familiar with ` database-generic ` .
2728
2829To run the tutorial on your machine:
29301 . Clone this repo.
Original file line number Diff line number Diff line change 22
33module Database.Generic.Entity.FromDb where
44
5- import Database.Generic.Prelude
65import Database.Generic.Entity.DbColumns (HasDbColumns )
76import Database.Generic.Entity.DbTypes (DbT (.. ), DbValue )
7+ import Database.Generic.Prelude
88import Generics.Eot qualified as G
99
1010data FromDbError dbv
Original file line number Diff line number Diff line change @@ -76,13 +76,7 @@ main = do
7676 info " Create table if not exists" $ createTable @ Person True
7777 info " Delete all" $ deleteAll @ Person -- Clear table before tutorial.
7878
79- let x = returning $ insertOne john -- Insert One (Just Person) Person
80- --
81- -- HasOutputType (Insert o (Just Person) a) where
82- -- outputType = OutputTypeRows
83- --
84- -- ParseOutput DbValue s where
85- info " Insert one" x
79+ info " Insert one" $ insertOne john
8680
8781 info " Insert many" $
8882 insertMany [Person 25 " Alice" True , Person 25 " Bob" False ]
You can’t perform that action at this time.
0 commit comments