mongo posting fix

v1.18.x
barisusakli 11 years ago
parent dc9754d77a
commit 10b30e303b

@ -18,7 +18,7 @@ module.exports = function(db, module) {
}
], function(err) {
if (typeof callback === 'function') {
callback(err, obj);
callback(err);
}
});
};
@ -42,7 +42,7 @@ module.exports = function(db, module) {
if (typeof callback === 'function') {
callback(err, obj);
}
});
});
} else {
if (typeof callback === 'function') {
callback(err, {});

@ -2,7 +2,7 @@
module.exports = function(db, module) {
var helpers = module.helpers.level;
module.listPrepend = function(key, value, callback) {
module.getListRange(key, 0, -1, function(err, list) {
var arr = list || [];
@ -17,7 +17,7 @@ module.exports = function(db, module) {
arr.push(value);
module.set(key, arr, function(err) {
if (typeof callback === 'function') {
callback(err, list);
callback(err);
}
});
});

@ -6,13 +6,15 @@ module.exports = function(db, module) {
var helpers = module.helpers.level;
module.setAdd = function(key, value, callback) {
callback = callback || function() {};
module.getListRange(key, 0, -1, function(err, set) {
if (err) {
return callback(err);
}
if (set.indexOf(value) === -1) {
module.listAppend(key, value, callback);
} else {
if (typeof callback === 'function') {
callback(null, []); // verify if it sends back true on redis?
}
callback(null);
}
});
};

@ -38,6 +38,9 @@
}
];
module.helpers = module.helpers || {};
module.helpers.mongo = require('./mongo/helpers');
module.init = function(callback) {
try {
mongoClient = require('mongodb').MongoClient;
@ -116,7 +119,5 @@
db.close();
};
module.helpers = module.helpers || {};
module.helpers.mongo = require('./mongo/helpers');
}(exports));

@ -6,7 +6,9 @@ module.exports = function(db, module) {
module.setObject = function(key, data, callback) {
callback = callback || helpers.noop;
data._key = key;
db.collection('objects').update({_key:key}, {$set:data}, {upsert:true, w: 1}, callback);
db.collection('objects').update({_key:key}, {$set:data}, {upsert:true, w: 1}, function(err) {
callback(err);
});
};
module.setObjectField = function(key, field, value, callback) {

@ -24,7 +24,9 @@ module.exports = function(db, module) {
}, {
upsert: true,
w: 1
}, callback);
}, function(err) {
callback(err);
});
};
module.setRemove = function(key, value, callback) {

@ -3,7 +3,9 @@
module.exports = function(redisClient, module) {
module.setObject = function(key, data, callback) {
callback = callback || function() {};
redisClient.hmset(key, data, callback);
redisClient.hmset(key, data, function(err) {
callback(err);
});
};
module.setObjectField = function(key, field, value, callback) {

@ -2,7 +2,10 @@
module.exports = function(redisClient, module) {
module.setAdd = function(key, value, callback) {
redisClient.sadd(key, value, callback);
callback = callback || function() {};
redisClient.sadd(key, value, function(err) {
callback(err);
});
};
module.setRemove = function(key, value, callback) {

@ -69,7 +69,7 @@ var async = require('async'),
function(postData, next) {
db.setObject('post:' + postData.pid, postData, next);
},
function(result, next) {
function(next) {
db.sortedSetAdd('posts:pid', timestamp, postData.pid);
db.incrObjectField('global', 'postCount');

@ -210,7 +210,7 @@ module.exports = function(Topics) {
function(next) {
Topics.markAsRead(tid, uid, next);
},
function(result, next) {
function(next) {
posts.getUserInfoForPosts([postData.uid], next);
},
function(userInfo, next) {

Loading…
Cancel
Save