mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
getObjectsFix
return empty array if keys is empty or not an array
This commit is contained in:
@@ -32,7 +32,7 @@ module.exports = function(db, module) {
|
|||||||
|
|
||||||
module.getObjects = function(keys, callback) {
|
module.getObjects = function(keys, callback) {
|
||||||
if (!Array.isArray(keys) || !keys.length) {
|
if (!Array.isArray(keys) || !keys.length) {
|
||||||
return callback();
|
return callback(null, []);
|
||||||
}
|
}
|
||||||
db.collection('objects').find({_key: {$in: keys}}, {_id: 0}).toArray(function(err, data) {
|
db.collection('objects').find({_key: {$in: keys}}, {_id: 0}).toArray(function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ var async = require('async'),
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Array.isArray(notifications) || !notifications.length) {
|
||||||
|
return callback(null, []);
|
||||||
|
}
|
||||||
|
|
||||||
async.map(notifications, function(notification, next) {
|
async.map(notifications, function(notification, next) {
|
||||||
if (!notification) {
|
if (!notification) {
|
||||||
return next(null, null);
|
return next(null, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user