Software / code / prosody
Comparison
plugins/mod_storage_sql2.lua @ 5969:0a3b8003ac9c
mod_storage_sql2: Expose the unique key argument, allowing arbitrary ids. Conflicting items are removed.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 25 Dec 2013 22:37:52 +0100 |
| parent | 5968:e1e9f1411442 |
| child | 5979:4c41404d9eec |
comparison
equal
deleted
inserted
replaced
| 5968:e1e9f1411442 | 5969:0a3b8003ac9c |
|---|---|
| 214 return iterator(result); | 214 return iterator(result); |
| 215 end | 215 end |
| 216 | 216 |
| 217 local archive_store = {} | 217 local archive_store = {} |
| 218 archive_store.__index = archive_store | 218 archive_store.__index = archive_store |
| 219 function archive_store:append(username, when, with, value) | 219 function archive_store:append(username, key, when, with, value) |
| 220 if value == nil then -- COMPAT early versions | |
| 221 when, with, value, key = key, when, with, value | |
| 222 end | |
| 220 local user,store = username,self.store; | 223 local user,store = username,self.store; |
| 221 return engine:transaction(function() | 224 return engine:transaction(function() |
| 222 local key = uuid.generate(); | 225 local key = key or uuid.generate(); |
| 223 local t, value = serialize(value); | 226 local t, value = serialize(value); |
| 227 engine:delete("DELETE FROM `prosodyarchive` WHERE `host`=? AND `user`=? AND `store`=? AND KEY=?", host, user or "", store, key); | |
| 224 engine:insert("INSERT INTO `prosodyarchive` (`host`, `user`, `store`, `when`, `with`, `key`, `type`, `value`) VALUES (?,?,?,?,?,?,?,?)", host, user or "", store, when, with, key, t, value); | 228 engine:insert("INSERT INTO `prosodyarchive` (`host`, `user`, `store`, `when`, `with`, `key`, `type`, `value`) VALUES (?,?,?,?,?,?,?,?)", host, user or "", store, when, with, key, t, value); |
| 225 return key; | 229 return key; |
| 226 end); | 230 end); |
| 227 end | 231 end |
| 228 | 232 |