From 84cbcc5a973bf1b2b9db33bb4f15bf2e124585f4 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Sat, 18 Jan 2014 22:23:25 -0500 Subject: [PATCH] closes #798 --- src/database/mongo.js | 8 ++++++++ src/database/redis.js | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/database/mongo.js b/src/database/mongo.js index 9890604cf2..b8bd6f0a64 100644 --- a/src/database/mongo.js +++ b/src/database/mongo.js @@ -230,6 +230,14 @@ }); } + module.rename = function(oldKey, newKey, callback) { + db.collection('objects').update({_key: oldKey}, {$set:{_key: newKey}}, function(err, result) { + if(callback) { + callback(err, result); + } + }); + } + module.expire = function(key, seconds, callback) { module.expireAt(key, Math.round(Date.now() / 1000) + seconds, callback); } diff --git a/src/database/redis.js b/src/database/redis.js index a5c8822b60..e8964b7a36 100644 --- a/src/database/redis.js +++ b/src/database/redis.js @@ -206,6 +206,10 @@ redisClient.keys(key, callback); } + module.rename = function(oldKey, newKey, callback) { + redisClient.rename(oldKey, newKey, callback); + } + module.expire = function(key, seconds, callback) { redisClient.expire(key, seconds, callback); }