Using arrayFilter option in node-red-mongodb node in node-red


I want to update an specific array element in a mongodb document.

How can I pass arrayFilter option to the mongodb node when I do the update.


Could you please explain a bit more? List out the seperate steps you are taking(planning on taking) to accomplish this.

Do you intend to retreive something from mongoldb and the result will have an array that you want to update an occurrence of that array then update the database with that result

OR do you want to send a value that, in an update statement, you want to change a particular occurance of a column in the database? How will you know what occurance to change?

(NOTE: not being a mongodb user, the 'terms' misght be incorrect - forgive me for that)

Hello zenofmud,

Thank you for your reply.

I have a mongodb document created using node-red-mongodb node.
This document contains an embedded nested array. I want to update the value of one specific array element in the inner array.

To do that, I need to pass options with arrayFilter option as an argument to the node-red-mongodb node. but the node support only msg.projection and msg.payload.

However, from further reading I figured out that this node does not support this because options have been hard coded within. Therefore no way of using this for that purpose. I am now looking at node-red-contrib-mongodb3. I think this would give the results I need.

 else if (node.operation === "update") {
                            if (typeof msg.payload !== "object") {
                                msg.payload = {"payload": msg.payload};
                            var query = msg.query || {};
                            var payload = msg.payload || {};
                            var options = {
                                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-red-contrib-mongodb3 solved the problem

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.