comparison tests/crud.ur @ 334:9601c717d2f3

queryX
author Adam Chlipala <adamc@hcoop.net>
date Sat, 13 Sep 2008 19:49:53 -0400
parents 02d15d81ae9b
children 34847732cefc
comparison
equal deleted inserted replaced
333:c655eddc3795 334:9601c717d2f3
12 end) = struct 12 end) = struct
13 13
14 open constraints M 14 open constraints M
15 val tab = M.tab 15 val tab = M.tab
16 16
17 fun list () = 17 fun main () : transaction page =
18 rows <- query (SELECT * FROM tab AS T) 18 rows <- queryX (SELECT * FROM tab AS T)
19 (fn (fs : {T : $([Id = int] ++ M.cols)}) acc => return <body> 19 (fn (fs : {T : $([Id = int] ++ M.cols)}) => <body>
20 {acc}
21 <tr> 20 <tr>
22 <td>{txt _ fs.T.Id}</td> 21 <td>{txt _ fs.T.Id}</td>
23 {foldTRX2 [idT] [colMeta'] [tr] 22 {foldTRX2 [idT] [colMeta'] [tr]
24 (fn (nm :: Name) (t :: Type) (rest :: {Type}) => 23 (fn (nm :: Name) (t :: Type) (rest :: {Type}) =>
25 [[nm] ~ rest] => 24 [[nm] ~ rest] =>
26 fn v funcs => <tr> 25 fn v funcs => <tr>
27 <td>{funcs.Show v}</td> 26 <td>{funcs.Show v}</td>
28 </tr>) 27 </tr>)
29 [M.cols] (fs.T -- #Id) M.cols} 28 [M.cols] (fs.T -- #Id) M.cols}
30 </tr> 29 </tr>
31 </body>) <body></body>; 30 </body>);
32 return <html><head> 31 return <html><head>
33 <title>List</title> 32 <title>{cdata M.title}</title>
34 33
35 </head><body> 34 </head><body>
36 35
37 <h1>List</h1> 36 <h1>{cdata M.title}</h1>
38 37
39 <table border={1}> 38 <table border={1}>
40 <tr> <th>ID</th> </tr> 39 <tr> <th>ID</th> </tr>
41 {rows} 40 {rows}
42 </table> 41 </table>
43 </body></html> 42 </body></html>
44 43
45 fun main () : transaction page = return <html><head>
46 <title>{cdata M.title}</title>
47 </head><body>
48 <h1>{cdata M.title}</h1>
49
50 <li> <a link={list ()}>List all rows</a></li>
51 </body></html>
52
53 end 44 end