webmcp
diff demo-app/model/tempstore.lua @ 0:9fdfb27f8e67
Version 1.0.0
author | jbe/bsw |
---|---|
date | Sun Oct 25 12:00:00 2009 +0100 (2009-10-25) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/demo-app/model/tempstore.lua Sun Oct 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,25 @@ 1.4 +Tempstore = mondelefant.new_class() 1.5 +Tempstore.table = 'tempstore' 1.6 + 1.7 +function Tempstore:by_key(key) 1.8 + local selector = self:new_selector() 1.9 + selector:add_where{ 'key = ?', key } 1.10 + selector:optional_object_mode() 1.11 + return selector:exec() 1.12 +end 1.13 + 1.14 +function Tempstore:data_by_key(key) 1.15 + local tempstore = Tempstore:by_key(key) 1.16 + if tempstore then 1.17 + tempstore:destroy() 1.18 + return tempstore.data 1.19 + end 1.20 +end 1.21 + 1.22 +function Tempstore:create(data) 1.23 + tempstore = Tempstore:new() 1.24 + tempstore.key = multirand.string(22, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') 1.25 + tempstore.data = data 1.26 + tempstore:save() 1.27 + return tempstore.key 1.28 +end