From 0fd69332c78d64e8a07b10196b229cc8e7c5a4b5 Mon Sep 17 00:00:00 2001 From: Freddy Thobhani Date: Wed, 17 May 2017 15:42:47 +0530 Subject: [PATCH] Added allowDiskUse oprion in mongodb node --- .DS_Store | Bin 0 -> 8196 bytes storage/mongodb/66-mongodb.js | 31 +++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3303570716d9b5c74b1177e600044479412307e8 GIT binary patch literal 8196 zcmeHMF>4e-6n=AeBntseVUa?}VjaXZ)@wK`8zHs9aCb=#_Ogd}hXk8#ECnkID=RVB zTl)tD5$r9s^C#qcGvm5%X10_Q@&;z!GVjg%zWH`;m$yem=3q76C)y#R44v)v7KTJ) zKliBh{LCJ#!FnoB_YX(aY#v4Ggess4r~;~hDxeDdFACtD%`NMA?>n!Ks(>nREfwJB zLype2@V0i=J~}Yi5&(99Y1?qU%@?q_w}rR0v+$r9w-nYbHNM0!ZaL<2A6Ix=JL{H{ z@x_Pn$i`PF#-byCZo|nG&g!TNr~Vgw(0$B8mJ zp%oa7XbCnIol8C+U!-D^e1belK0%D&V}3h6XHe%Ejp@0y6Tv6@#gD*@f|w+qDCX~d zYV-+W1fQEfm`{&Y5gg2y`+w#WxHdkqcRMfg_rG%fO`6+%E@*;X2dAMtiX#%3L5>7^ z5FvP&$IN2`r?J8*nDW^a`|ZEy0O3z?2>g-O!Y}YQybcSTzzP~1L4N# z95%6sR*s|&B0})!-D4dF$S~nNLId;WPTQBjZq_AG8=t^)=be31ngu(iSD!qd^>yHR zU!--DQ{wUVaNbrHu>|UpF2pYB(a$&{fgR*X>^O)JJm@p?(54EkQ-Qt%-{JcIVfXj{ zby8GpRX`Q^#|oIi@Njql5MNtIa9nHW=ugqPaa`@JU4p@u8m XJBt~#HGBvN-pu;`w>LtEYo)*yvDjyU literal 0 HcmV?d00001 diff --git a/storage/mongodb/66-mongodb.js b/storage/mongodb/66-mongodb.js index a8f66f35a..8dbf1dc84 100644 --- a/storage/mongodb/66-mongodb.js +++ b/storage/mongodb/66-mongodb.js @@ -244,16 +244,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); + } + }); } - }); - } + } }); } });