Update in Mongo

I use the update function, when I select the update key, which is nested in mong, the data is not updated

I think you might need to add the Use Dot Notation option to your node to get this working.

unfortunately it didn’t help

Hey @sfedosej

Are you seeing any error when running or seems like it completes okay but the data isn’t showing? If you do get an error I can try help further troubleshoot it.

Best regards,

Samuel

Hi!
Input:

[

{

"_id": "gggg",

"verified": {

"email": true,

"phone": false

},

"profile": {

"email": "[email protected]",

"name": "name",

"surname": "",

"agreement": false,

"middlename": "",

"login": "login"

}}]

Output looks like this:
[

{

}

]

I would be grateful if
you could help.

The support for dot-notation on an update in the MongoDB node is full of quirks and odd side-effects.

Alternative, More Reliable Approach

  1. Load the existing MongoDB document/object by query, which will include the _id field/value
  2. Modify/add whatever fields you need to, even in nested documents.
  3. Update using Key_id, specifying/including all root-level Fields
    • Get the list of all root-level fields except _id with an expression like:
      {{ $json.keys().filter((key) => ['id','_id'].indexOf(key) === -1).join(',') }}
1 Like