Merge 0fd69332c78d64e8a07b10196b229cc8e7c5a4b5 into aa45796a98e878fdfa7d845eb74abb7254bac9c6

This commit is contained in:
Freddy Thobhani 2020-09-27 23:02:39 +02:00 committed by GitHub
commit 549c4753cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 8 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -274,16 +274,31 @@ module.exports = function(RED) {
}
else if (node.operation === "aggregate") {
msg.payload = (Array.isArray(msg.payload)) ? msg.payload : [];
coll.aggregate(msg.payload, function(err, result) {
if (err) {
node.error(err);
if(msg.allowDiskUse == true){
var cursor = coll.aggregate(msg.payload, {allowDiskUse: true});
cursor.each(processCursor);
function processCursor(err, result){
if(err){
err = "custom error: " +err;
node.error(err);
} else{
msg.payload = result;
node.send(msg);
}
}
else {
msg.payload = result;
node.send(msg);
} else{
coll.aggregate(msg.payload,function(err,result)){
if(err){
node.error(err);
} else {
msg.payload = result;
msg.send(msg);
}
});
}
});
}
}
});
}
});