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