diff --git a/storage/mongodb/66-mongodb.html b/storage/mongodb/66-mongodb.html
index ad44cb23..c81f4cbb 100644
--- a/storage/mongodb/66-mongodb.html
+++ b/storage/mongodb/66-mongodb.html
@@ -106,7 +106,8 @@
Insert will insert a new object.
Save and insert either store msg
or msg.payload
.
Update will modify an existing object or objects. The query to select objects to update uses msg.query
- and the update to the element uses msg.payload
.
+ and the update to the element uses msg.payload
. If msg.query._id
is
+ a valid mongo ObjectId string it will be converted to an ObjectId type.
Update can add a object if it does not exist or update multiple objects.
Remove will remove objects that match the query passed in on msg.payload
. A blank query will delete
all of the objects in the collection.
diff --git a/storage/mongodb/66-mongodb.js b/storage/mongodb/66-mongodb.js
index 2be88b26..2cf65681 100644
--- a/storage/mongodb/66-mongodb.js
+++ b/storage/mongodb/66-mongodb.js
@@ -17,6 +17,7 @@
module.exports = function(RED) {
"use strict";
var mongo = require('mongodb');
+ var ObjectID = require('mongodb').ObjectID;
var MongoClient = mongo.MongoClient;
function MongoNode(n) {
@@ -136,7 +137,9 @@ module.exports = function(RED) {
upsert: node.upsert,
multi: node.multi
};
-
+ if (ObjectID.isValid(msg.query._id)) {
+ msg.query._id = new ObjectID(msg.query._id);
+ }
coll.update(query, payload, options, function(err, item) {
if (err) {
node.error(err,msg);
diff --git a/storage/mongodb/package.json b/storage/mongodb/package.json
index bb691e8c..a3901614 100644
--- a/storage/mongodb/package.json
+++ b/storage/mongodb/package.json
@@ -1,9 +1,9 @@
{
"name" : "node-red-node-mongodb",
- "version" : "0.0.7",
+ "version" : "0.0.8",
"description" : "Node-RED nodes to talk to an Mongo database",
"dependencies" : {
- "mongodb" : "^2.2.5"
+ "mongodb" : "^2.2.11"
},
"repository" : {
"type":"git",