view demo/tree.ur @ 708:1a317a707d71

Add primary keys to demo
author Adam Chlipala <>
date Tue, 07 Apr 2009 16:22:11 -0400
parents 20fab0e96217
children 1db127b245ed
line wrap: on
line source
sequence s
table t : { Id : int, Parent : option int, Nam : string }

open TreeFun.Make(struct
                      val tab = t

fun row r = <xml>
  #{[r.Id]}: {[r.Nam]} <a link={del r.Id}>[Delete]</a>

    Add child: <textbox{#Nam}/> <submit action={add (Some r.Id)}/>

and main () =
    xml <- tree row None;
    return <xml><body>

        Add a top-level node: <textbox{#Nam}/> <submit action={add None}/>

and add parent r =
    id <- nextval s;
    dml (INSERT INTO t (Id, Parent, Nam) VALUES ({[id]}, {[parent]}, {[r.Nam]}));
    main ()

and del id =
    dml (DELETE FROM t WHERE Id = {[id]});
    main ()