1 enum sex {
    2 	item male jslabel "male"
    3 		jslabel.fr "le mâle"
    4 		comment "Male"; # value 0
    5 	item female jslabel "female"
    6 		jslabel.fr "la femelle"
    7 		comment "Female"; # value 1
    8 	item other jslabel "other"
    9 		jslabel.fr "l'autre"
   10 		comment "Other"; # value 2
   11 	comment "Birthsex of individual";
   12 };
   13 
   14 struct company {
   15 	field name text limit gt 0
   16 		comment "Name of the organisation.";
   17 	field id int rowid;
   18 	field somenum int null
   19 		comment "Simply a check for null values.";
   20 	list somenum isnull;
   21 	delete;
   22 	insert;
   23 	comment "Controlling organisation.";
   24 };
   25 
   26 struct user {
   27 	field company struct cid
   28 		comment "This struct will be filled in from an inner join
   29     on the \"cid\" variable.";
   30 	field cid:company.id int actdel cascade
   31 		comment "A foreign key reference.";
   32 	field sex enum sex
   33 		comment "User's birth sex.";
   34 	field hash password limit gt 0
   35 		comment "Password hash.
   36     This is passed to inserts and updates as a password,
   37     then hashed within the implementation and extracted
   38     (in listings and searches) as the hash value.";
   39 	field email email unique
   40 		comment "Unique e-mail address.";
   41 	field image blob null
   42 		comment "A PNG image or something.";
   43 	field name text
   44 		comment "User's full name.";
   45 	field uid int rowid;
   46 	iterate name: limit 5
   47 		comment "Create a function that searches for users by a given
   48     name; and, when found, invokes a callback function
   49     provided the user structure.";
   50 	search email, hash: name creds
   51 		comment "Search for a unique user with their e-mail and
   52     password.
   53     This is a quick way to verify that a user has entered
   54     the correct password for logging in.";
   55 	search uid: order company.name
   56 		comment "Lookup by unique identifier.";
   57 	update hash: uid;
   58 	update email: uid;
   59 	delete;
   60 	insert;
   61 	comment "A regular user.";
   62 };
   63 
   64 struct session {
   65 	field user struct userid;
   66 	field userid:user.uid int
   67 		comment "Associated user.";
   68 	field token int
   69 		comment "Random cookie.";
   70 	field mtime epoch;
   71 	field id int rowid;
   72 	iterate user.company.name, mtime: name foo
   73 		comment "Search for company's logged-in users.";
   74 	delete id;
   75 	insert;
   76 	comment "Authenticated session.";
   77 };
   78