My original document was like this
`{
"_id": 1,
"item": "abc",
"price": 10,
"quantity": 2,
"product": "A"
},
{
"_id": 2,
"item": "jkl",
"price": 20,
"quantity": 1,
"product": "B"
}`
I used the below query to swap the product A and B, using the $set and $switch operators
`{$set:{
"product": { $switch : {
branches: [
{case : "A", then : "B"},
{case : "B", then : "A"},
]
}}
}}`
My document got updated like this
`{
"_id": 1,
"item": "abc",
"price": 10,
"quantity": 2,
"product": {
"$switch": {
"branches": [
{
"case": "A",
"then": "B"
},
{
"case": "B",
"then": "A"
}
]
}
}
}`
Can any one explain this behaviour? I was expecting a result like below
`{
"_id": 1,
"item": "jkl",
"price": 20,
"quantity": 1,
"product": "B"
}`