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