MongoDB Update One

I have an issue in mongoDB node. I have a document
{“_id”:{“$oid”:“68c7d12ad6b9a7d17d019517”},“param_name”:“ITEM_DETAILS”,“provider_code”:“ZOHO”,“param_value”:{“XYZ”:{“item_id”:“ZOHO_ITEM_1001”,“rate”:{“$numberInt”:“499”}},“ABC”:{“item_id”:“ZOHO_ITEM_1001”,“rate”:{“$numberInt”:“345”}}}}

Inside the param value I want to check any item exist or not ley say XYZ exist . so I dont append new item if not exist I want to append inside param_value with new item. how to do it.

I want to append

[
{
“MNO”: {
“item_id”: “ZOHO_ITEM”,
“rate”: 5
}
}

which node should I use
]

Hey @Kanhaiya_Gupta hope all is good.

Imagine you have the following documents:

as you can see three of them do have XYZ and other three - don’t.

This is the workflow you could run:

And here is the result:

As you can see, the records which didn’t hav XYZ, now have MNO.

If you wish me to look at your workflow, please provide a reproducible example with input data and format it with preformatted text tags, avoid dropping the JSON directly as text, as it becomes formatted and requires cleanup before it can be pasted into n8n. Thank you.

hey @jabbson its resolved. I have to use dot operator for this.

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