mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-18 03:31:03 +01:00
fix mongo setObject if key/value is empty string
This commit is contained in:
@@ -8,7 +8,9 @@ module.exports = function (db, module) {
|
||||
if (!key || !data) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty('')) {
|
||||
delete data[''];
|
||||
}
|
||||
db.collection('objects').update({ _key: key }, { $set: data }, { upsert: true, w: 1 }, function (err) {
|
||||
callback(err);
|
||||
});
|
||||
|
||||
@@ -8,11 +8,17 @@ module.exports = function (redisClient, module) {
|
||||
if (!key || !data) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty('')) {
|
||||
delete data[''];
|
||||
}
|
||||
|
||||
Object.keys(data).forEach(function (key) {
|
||||
if (data[key] === undefined) {
|
||||
delete data[key];
|
||||
}
|
||||
});
|
||||
|
||||
redisClient.hmset(key, data, function (err) {
|
||||
callback(err);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user