1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Make simple payload types be objects for mongodb to stor sensibly.

This commit is contained in:
Dave C-J 2013-10-31 16:33:14 +00:00
parent bbc1b70a5a
commit 8891548909

View File

@ -47,12 +47,18 @@ function MongoOutNode(n) {
node.on("input",function(msg) { node.on("input",function(msg) {
if (node.operation == "store") { if (node.operation == "store") {
delete msg._topic; delete msg._topic;
if (node.payonly) coll.save(msg.payload,function(err,item){ if (err){node.error(err);} }); if (node.payonly) {
if (typeof msg.payload !== "object") { msg.payload = {"payload":msg.payload}; }
coll.save(msg.payload,function(err,item){ if (err){node.error(err);} });
}
else coll.save(msg,function(err,item){if (err){node.error(err);}}); else coll.save(msg,function(err,item){if (err){node.error(err);}});
} }
else if (node.operation == "insert") { else if (node.operation == "insert") {
delete msg._topic; delete msg._topic;
if (node.payonly) coll.insert(msg.payload,function(err,item){ if (err){node.error(err);} }); if (node.payonly) {
if (typeof msg.payload !== "object") { msg.payload = {"payload":msg.payload}; }
coll.insert(msg.payload,function(err,item){ if (err){node.error(err);} });
}
else coll.insert(msg,function(err,item){if (err){node.error(err);}}); else coll.insert(msg,function(err,item){if (err){node.error(err);}});
} }
if (node.operation == "delete") { if (node.operation == "delete") {