mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
mongo posting fix
This commit is contained in:
@@ -18,7 +18,7 @@ module.exports = function(db, module) {
|
|||||||
}
|
}
|
||||||
], function(err) {
|
], function(err) {
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(err, obj);
|
callback(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -42,7 +42,7 @@ module.exports = function(db, module) {
|
|||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(err, obj);
|
callback(err, obj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(err, {});
|
callback(err, {});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module.exports = function(db, module) {
|
module.exports = function(db, module) {
|
||||||
var helpers = module.helpers.level;
|
var helpers = module.helpers.level;
|
||||||
|
|
||||||
module.listPrepend = function(key, value, callback) {
|
module.listPrepend = function(key, value, callback) {
|
||||||
module.getListRange(key, 0, -1, function(err, list) {
|
module.getListRange(key, 0, -1, function(err, list) {
|
||||||
var arr = list || [];
|
var arr = list || [];
|
||||||
@@ -17,7 +17,7 @@ module.exports = function(db, module) {
|
|||||||
arr.push(value);
|
arr.push(value);
|
||||||
module.set(key, arr, function(err) {
|
module.set(key, arr, function(err) {
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(err, list);
|
callback(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,13 +6,15 @@ module.exports = function(db, module) {
|
|||||||
var helpers = module.helpers.level;
|
var helpers = module.helpers.level;
|
||||||
|
|
||||||
module.setAdd = function(key, value, callback) {
|
module.setAdd = function(key, value, callback) {
|
||||||
|
callback = callback || function() {};
|
||||||
module.getListRange(key, 0, -1, function(err, set) {
|
module.getListRange(key, 0, -1, function(err, set) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
if (set.indexOf(value) === -1) {
|
if (set.indexOf(value) === -1) {
|
||||||
module.listAppend(key, value, callback);
|
module.listAppend(key, value, callback);
|
||||||
} else {
|
} else {
|
||||||
if (typeof callback === 'function') {
|
callback(null);
|
||||||
callback(null, []); // verify if it sends back true on redis?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -38,6 +38,9 @@
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
module.helpers = module.helpers || {};
|
||||||
|
module.helpers.mongo = require('./mongo/helpers');
|
||||||
|
|
||||||
module.init = function(callback) {
|
module.init = function(callback) {
|
||||||
try {
|
try {
|
||||||
mongoClient = require('mongodb').MongoClient;
|
mongoClient = require('mongodb').MongoClient;
|
||||||
@@ -116,7 +119,5 @@
|
|||||||
db.close();
|
db.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.helpers = module.helpers || {};
|
|
||||||
module.helpers.mongo = require('./mongo/helpers');
|
|
||||||
}(exports));
|
}(exports));
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ module.exports = function(db, module) {
|
|||||||
module.setObject = function(key, data, callback) {
|
module.setObject = function(key, data, callback) {
|
||||||
callback = callback || helpers.noop;
|
callback = callback || helpers.noop;
|
||||||
data._key = key;
|
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) {
|
module.setObjectField = function(key, field, value, callback) {
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ module.exports = function(db, module) {
|
|||||||
}, {
|
}, {
|
||||||
upsert: true,
|
upsert: true,
|
||||||
w: 1
|
w: 1
|
||||||
}, callback);
|
}, function(err) {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.setRemove = function(key, value, callback) {
|
module.setRemove = function(key, value, callback) {
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
module.exports = function(redisClient, module) {
|
module.exports = function(redisClient, module) {
|
||||||
module.setObject = function(key, data, callback) {
|
module.setObject = function(key, data, callback) {
|
||||||
callback = callback || function() {};
|
callback = callback || function() {};
|
||||||
redisClient.hmset(key, data, callback);
|
redisClient.hmset(key, data, function(err) {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.setObjectField = function(key, field, value, callback) {
|
module.setObjectField = function(key, field, value, callback) {
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
module.exports = function(redisClient, module) {
|
module.exports = function(redisClient, module) {
|
||||||
module.setAdd = function(key, value, callback) {
|
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) {
|
module.setRemove = function(key, value, callback) {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ var async = require('async'),
|
|||||||
function(postData, next) {
|
function(postData, next) {
|
||||||
db.setObject('post:' + postData.pid, postData, next);
|
db.setObject('post:' + postData.pid, postData, next);
|
||||||
},
|
},
|
||||||
function(result, next) {
|
function(next) {
|
||||||
db.sortedSetAdd('posts:pid', timestamp, postData.pid);
|
db.sortedSetAdd('posts:pid', timestamp, postData.pid);
|
||||||
|
|
||||||
db.incrObjectField('global', 'postCount');
|
db.incrObjectField('global', 'postCount');
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ module.exports = function(Topics) {
|
|||||||
function(next) {
|
function(next) {
|
||||||
Topics.markAsRead(tid, uid, next);
|
Topics.markAsRead(tid, uid, next);
|
||||||
},
|
},
|
||||||
function(result, next) {
|
function(next) {
|
||||||
posts.getUserInfoForPosts([postData.uid], next);
|
posts.getUserInfoForPosts([postData.uid], next);
|
||||||
},
|
},
|
||||||
function(userInfo, next) {
|
function(userInfo, next) {
|
||||||
|
|||||||
Reference in New Issue
Block a user