MongoDB Out Node - Issues with _id on Update

#1

Good Day,

I am attempting to do an update (overwrite) to MongoDB via the mongodb out node.

The notes suggest "... if you want repeated entries to overwrite, then you must set the msg._id property to be a constant by the use of a previous function node."

To test an INSERT, I set msg._id = 1111 in a function node and send that off with the payload and the record is correctly inserted into the db.

I then attempt to do a further INSERT, and get: "MongoError: E11000 duplicate key error collection: tempmdb.userConfig index: id dup key: { : 1111 }".

So far so good, I'm happy the the key is working.

Then I change the mongodb node out operation to UPDATE, and I get: "TypeError: Cannot read property '_id' of undefined".

What am I doing wrong?

Thanks in advance.

0 Likes

#2

which of the many mongo nodes are you using?

0 Likes

#3

node-red-node-mongodb

image

0 Likes