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

update to mongodb node to allow both save and insert.

This commit is contained in:
Dave C-J 2013-10-28 09:58:56 +00:00
parent 488a039781
commit c193779f67
2 changed files with 41 additions and 35 deletions

View File

@ -60,8 +60,9 @@
<div class="form-row">
<label for="node-input-operation"><i class="icon-wrench"></i> Operation</label>
<select type="text" id="node-input-operation" style="display: inline-block; vertical-align: top;">
<option value=store>Store</option>
<option value=delete>Delete</option>
<option value=store>save</option>
<option value=insert>insert</option>
<option value=delete>remove</option>
</select>
</div>
<div class="form-row node-input-payonly">

View File

@ -50,6 +50,11 @@ function MongoOutNode(n) {
if (node.payonly) 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);} });
else coll.insert(msg,function(err,item){if (err){node.error(err);}});
}
if (node.operation == "delete") {
coll.remove(msg.payload, {w:1}, function(err, items){ if (err) node.error(err); });
}