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:
parent
bbc1b70a5a
commit
8891548909
@ -47,12 +47,18 @@ function MongoOutNode(n) {
|
||||
node.on("input",function(msg) {
|
||||
if (node.operation == "store") {
|
||||
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 if (node.operation == "insert") {
|
||||
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);}});
|
||||
}
|
||||
if (node.operation == "delete") {
|
||||
|
Loading…
Reference in New Issue
Block a user