Skip to content

Commit 32a7edf

Browse files
committed
tidy tutorial
1 parent 22bf171 commit 32a7edf

File tree

2 files changed

+47
-44
lines changed

2 files changed

+47
-44
lines changed

README.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,33 @@ To run the tutorial on your machine:
3232

3333
## Features
3434

35-
| Feature | Status | Tested |
36-
|------------------------------------------|--------|--------|
37-
| Create table |||
38-
| Select all |||
39-
| Select by ID |||
40-
| Return subset of fields |||
41-
| Where column equals | | |
42-
| Where column is null | | |
43-
| Where column is not null | | |
44-
| Order by clause |||
45-
| Order by asc/desc | | |
46-
| Limit clause |||
47-
| Offset clause |||
48-
| Insert one || |
49-
| Insert many || |
50-
| Insert returning || |
51-
| Delete all |||
52-
| Delete by ID |||
53-
| Delete returning |||
54-
| Joins | | |
55-
| Stream statements over Conduit | | |
56-
| Stream updates over Conduit | | |
57-
| Server: endpoint to execute statement || |
58-
| Server: stream statements over WebSocket | | |
59-
| Server: stream updates over WebSocket | | |
60-
| Server: permission checks | | |
61-
| Reflex (client-side) MonadDb instance | | |
35+
Examples of the following features can be found in [the
36+
tutorial](tutorial/tutorial/Main.hs).
37+
38+
| Feature | In Tutorial | Tested |
39+
|------------------------------------------|-------------|--------|
40+
| Create table |||
41+
| Insert one || |
42+
| Insert many || |
43+
| Insert returning || |
44+
| Insert returning fields |||
45+
| Select by ID |||
46+
| Select all |||
47+
| Select returning fields |||
48+
| Where column equals | | |
49+
| Where column is null | | |
50+
| Where column is not null | | |
51+
| Limit clause |||
52+
| Offset clause |||
53+
| Order by clause |||
54+
| Delete by ID |||
55+
| Delete all |||
56+
| Delete returning |||
57+
| Server: endpoint to execute statement || |
58+
| Joins | | |
59+
| Stream statements over Conduit | | |
60+
| Stream updates over Conduit | | |
61+
| Server: stream statements over WebSocket | | |
62+
| Server: stream updates over WebSocket | | |
63+
| Server: permission checks | | |
64+
| Reflex (client-side) MonadDb instance | | |

tutorial/tutorial/Main.hs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,38 +74,38 @@ main = do
7474
print =<< runAppM c (tx $ execute s)
7575

7676
info "Create table if not exists" $ createTable @Person True
77-
78-
info "Delete all" $ deleteAll @Person
79-
80-
info "Delete by ID" $ deleteById @Person "John"
77+
info "Delete all" $ deleteAll @Person -- Clear table before tutorial.
8178

8279
info "Insert one" $ returning $ insertOne $ john
8380

84-
info "Delete all, returning" $ deleteAll @Person
81+
info "Insert many" $
82+
insertMany [Person 25 "Alice", Person 25 "Bob"]
8583

86-
info "Insert many, returning age" $
87-
insertMany [john, Person 25 "Bob", Person 25 "Mary"] ==> field @"age"
84+
info "Insert many, returning" $
85+
returning $ insertMany [Person 26 "Charlie", Person 26 "Dee"]
8886

89-
info "Select by ID" $ selectById @Person john.name
87+
info "Insert many, returning age" $
88+
insertMany [Person 27 "Enid", Person 27 "Flavio"] ==> field @"age"
9089

9190
info "Select all" $ selectAll @Person
9291

93-
info "Select all, select 1 fields" $
92+
info "Select by PK" $ selectById @Person "John"
93+
94+
info "Select all, returning two fields" $
9495
selectAll @Person ==> (field @"age" /\ field @"name")
9596

96-
info "Select all, order by age" $
97-
orderBy (order @"age" @Desc) $ selectAll @Person
97+
info "Select all, order by age then name" $
98+
orderBy (order @"age" @Desc /\ order @"name" @Asc) $ selectAll @Person
9899

99100
info "Select all, limit 1" $
100101
limit 1 $ orderBy (order @"name" @Asc) $ selectAll @Person
101102

102-
info "Select all, order by (name desc, age asc), limit 1, offset 2"
103-
$ limitOffset 1 2
104-
$ orderBy (order @"age" @Asc /\ order @"name" @Asc)
105-
$ selectAll @Person
103+
info "Select all, order by name, limit 1, offset 2"
104+
$ limitOffset 1 2 $ orderBy (order @"name" @Asc) $ selectAll @Person
105+
106+
info "Delete by PK" $ deleteById @Person "John"
106107

107-
info "Select specific fields by ID" $
108-
selectById @Person john.name ==> field @"age"
108+
info "Delete all, returning" $ returning $ deleteAll @Person
109109

110110
putStrLn "\nStarting a server which will proxy any statements"
111111
Server.run (runAppM c) 1234 Server.developmentCors

0 commit comments

Comments
 (0)