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