Update value of field based on another array field

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:


I tried hardcoding 0 with this query, but as a result my price field is gone:


How can I accomplish this? thanks

1 Like