comparison tests/crud.ur @ 325:e457d8972ff1

Crud listing IDs
author Adam Chlipala <adamc@hcoop.net>
date Thu, 11 Sep 2008 17:41:52 -0400
parents
children 950320f33232
comparison
equal deleted inserted replaced
324:b91480c9a729 325:e457d8972ff1
1 functor Make(M : sig
2 con cols :: {Type}
3 constraint [Id] ~ cols
4 val tab : sql_table ([Id = int] ++ cols)
5
6 val title : string
7
8 val cols : $(mapTT (fn t => {Show : t -> xbody}) cols)
9 end) = struct
10
11 open constraints M
12 val tab = M.tab
13
14 fun list () =
15 rows <- query (SELECT * FROM tab AS T)
16 (fn fs acc => return <body>
17 {acc} <tr> <td>{txt _ fs.T.Id}</td> </tr>
18 </body>) <body></body>;
19 return <html><head>
20 <title>List</title>
21
22 </head><body>
23
24 <h1>List</h1>
25
26 <table border={1}>
27 <tr> <th>ID</th> </tr>
28 {rows}
29 </table>
30 </body></html>
31
32 fun main () : transaction page = return <html><head>
33 <title>{cdata M.title}</title>
34 </head><body>
35 <h1>{cdata M.title}</h1>
36
37 <li> <a link={list ()}>List all rows</a></li>
38 </body></html>
39
40 end