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