Hello, I have this document structure:
{
"price": 0,
"records": [
{"code": "x", "price": 1},
{"code": "x", "price": 2},
],
"current_price_index_at": 0,
}
I want to update price using price of an element of records that match the current_price_index_at. Something like this:
$records.$[current_price_index_at].price
I tried hardcoding 0 with this query, but as a result my price field is gone:
"command":{"findAndModify":"task","new":true,"query":{"_id":"74007479-2739-4ad1-8874-dc77f353e93a","update":[{"$set":{"updated_at":{"$date":"2021-11-08T08:27:32.227Z"},"price":"$records[0].price"}}]
How can I accomplish this? thanks