hesql-0.2: example/Account.hesql
module Account.DB where
-- see README for the table definitions
verifyLogin login' password' =
select1' Accountid, Login, RealName, Email from Account
where (password is null or password = md5(password')) and Lower(Login) = Lower(login')
and not Locked;
login accountid' =
update Account set LoggedIn = true where AccountID = accountid';
logout accountid' =
update Account
set LoggedIn = false,
LastLogout = Now()
where AccountID = accountid';
createAccount login password email realname =
insert into Account (Login, Password, Email, RealName) values (login,md5(password),email,realname);
activeUsers =
select Login from Account
where LoggedIn and
now() - LastRequest < '00:05:00';