mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 02:36:16 +01:00
fix decr/incrObjectField if key in array doesn't exist create it
This commit is contained in:
@@ -289,7 +289,10 @@ module.exports = function (db, module) {
|
||||
|
||||
if (Array.isArray(key)) {
|
||||
var bulk = db.collection('objects').initializeUnorderedBulkOp();
|
||||
bulk.find({ _key: { $in: key } }).upsert().update({ $inc: data });
|
||||
key.forEach(function (key) {
|
||||
bulk.find({ _key: key }).upsert().update({ $inc: data });
|
||||
});
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
bulk.execute(function (err) {
|
||||
|
||||
Reference in New Issue
Block a user