annotate 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
rev   line source
adamc@678 1 sequence s
adamc@678 2 table t : { Id : int, Title : string, Chan : option (channel string) }
adamc@678 3
adamc@678 4 fun list () =
adamc@678 5 queryX (SELECT * FROM t)
adamc@678 6 (fn r => <xml><tr>
adamc@678 7 <td>{[r.T.Id]}</td> <td>{[r.T.Title]}</td>
adamc@678 8 <td><a link={delete r.T.Id}>[delete]</a></td>
adamc@678 9 </tr></xml>)
adamc@678 10
adamc@678 11 and delete id =
adamc@678 12 dml (DELETE FROM t WHERE Id = {[id]});
adamc@678 13 main ()
adamc@678 14
adamc@678 15 and main () : transaction page =
adamc@678 16 let
adamc@678 17 fun create r =
adamc@678 18 id <- nextval s;
adamc@678 19 dml (INSERT INTO t (Id, Title, Chan) VALUES ({[id]}, {[r.Title]}, NULL));
adamc@678 20 main ()
adamc@678 21 in
adamc@678 22 ls <- list ();
adamc@678 23 return <xml><body>
adamc@678 24 <table>
adamc@678 25 <tr> <th>ID</th> <th>Title</th> </tr>
adamc@678 26 {ls}
adamc@678 27 </table>
adamc@678 28
adamc@678 29 <h1>New Channel</h1>
adamc@678 30
adamc@678 31 <form>
adamc@678 32 Title: <textbox{#Title}/><br/>
adamc@678 33 <submit action={create}/>
adamc@678 34 </form>
adamc@678 35 </body></xml>
adamc@678 36 end