Hi,
I maybe confused about how to use this positional operator so please help me.
I have this data:
[
{
"resource_id": "Machine-1",
"resource_descr": "Machine Number 1",
"components": [
{
"component_id": "mach-deas97u",
"component_type": "Housing",
"component_descr": "Housing 1"
},
{
"component_id": "mach-7b83ta0",
"component_type": "Base",
"component_descr": "Base 1"
},
{
"component_id": "mach-d1mxmd2",
"component_type": "Peripherals",
"component_descr": "Peripherals 1"
}
]
}
]
I only wanted to change the values of the component_descr of each of my array values coming from my web application.
I am expecting an output similar to this one:
{
"resource_id": "Machine-1",
"resource_descr": "Machine Number 1",
"components": [
{
"component_id": "mach-deas97u",
"component_type": "Housing",
"component_descr": "Housing 2"
},
{
"component_id": "mach-7b83ta0",
"component_type": "Base",
"component_descr": "Base 2"
},
{
"component_id": "mach-d1mxmd2",
"component_type": "Peripherals",
"component_descr": "Peripherals 2"
}
]
}
Note that the “component_descr” could be different for each object.
I was looking at the $[] operator but I am having trouble coming up with the solution.
I tried using this playground MongoDB Playground but it is not what I expected.
Can somebody please point me to the correct process? Thanks.