Update MongoDB document with a child record

#1

Hi, I am pretty new to Node-Red. I have a Mongodb with an existing record, "{
"_id" : ObjectId("5c6227be3579f60c5431b66b"),
"Title" : "Mr",
"Instance" : "HQ",
"FirstName" : "ppp",
"LastName" : "Phillips",
"Position" : "BF",
"EmailAddress" : "contact@paulphillips.guru"
}"

I have a workflow that expects a HTTP Post with the following:"
"_id":"5c6227be3579f60c5431b66b",
"Instance": "HQ",
"PPE":[
{
"Code": "PPE",
"Status": "New",
"Title": "Trousers",
"Type": "STD",
"Size": "10111116",
"Qty": 1,
"LostDamage": {
"Reason": "asdaD",
"Location": "Station",
"Damage": "Damged"
}
},
{
"Code": "PPEOPP",
"Status": "New",
"Title": "TrousASDASDASDers",
"Type": "STD",
"Size": "10111116",
"Qty": 1,
"LostDamage": {
"Reason": "asdaD",
"Location": "Station",
"Damage": "Damged"
}
}]
}
"
The "_id" is the parent record which I want to append the second child document too, so it should look something like this:"{
"_id" : ObjectId("5c6227be3579f60c5431b66b"),
"Title" : "Mr",
"Instance" : "HQ",
"FirstName" : "ppp",
"LastName" : "Phillips",
"Position" : "BF",
"EmailAddress" : "contact@paulphillips.guru",
"PPE" : [
{
"Code" : "PPE",
"Status" : "New",
"Title" : "Trousers",
"Type" : "STD",
"Size" : "10111116",
"Qty" : 1,
"LostDamage" : {
"Reason" : "asdaD",
"Location" : "Station",
"Damage" : "Damged"
}
},
{
"Code" : "PPEOPP",
"Status" : "New",
"Title" : "TrousASDASDASDers",
"Type" : "STD",
"Size" : "10111116",
"Qty" : 1,
"LostDamage" : {
"Reason" : "asdaD",
"Location" : "Station",
"Damage" : "Damged"
}
}
]
}"

Any ideas?

0 Likes