Mercurial > urweb
comparison tests/chat.ur @ 678:5ff1ff38e2db
Preliminary work supporting channels in databases
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 26 Mar 2009 16:22:34 -0400 |
parents | |
children | 44f23712020d |
comparison
equal
deleted
inserted
replaced
677:81573f62d6c3 | 678:5ff1ff38e2db |
---|---|
1 sequence s | |
2 table t : { Id : int, Title : string, Chan : option (channel string) } | |
3 | |
4 fun list () = | |
5 queryX (SELECT * FROM t) | |
6 (fn r => <xml><tr> | |
7 <td>{[r.T.Id]}</td> <td>{[r.T.Title]}</td> | |
8 <td><a link={delete r.T.Id}>[delete]</a></td> | |
9 </tr></xml>) | |
10 | |
11 and delete id = | |
12 dml (DELETE FROM t WHERE Id = {[id]}); | |
13 main () | |
14 | |
15 and main () : transaction page = | |
16 let | |
17 fun create r = | |
18 id <- nextval s; | |
19 dml (INSERT INTO t (Id, Title, Chan) VALUES ({[id]}, {[r.Title]}, NULL)); | |
20 main () | |
21 in | |
22 ls <- list (); | |
23 return <xml><body> | |
24 <table> | |
25 <tr> <th>ID</th> <th>Title</th> </tr> | |
26 {ls} | |
27 </table> | |
28 | |
29 <h1>New Channel</h1> | |
30 | |
31 <form> | |
32 Title: <textbox{#Title}/><br/> | |
33 <submit action={create}/> | |
34 </form> | |
35 </body></xml> | |
36 end |