Database

[{"product_id":"10001","product_name":"Banana","product_date":"2022-10-20T00:00:00.000+00:00","product_price":255.15,"dates":{"2022-10-20":{"recorded_price":195.15},"2022-10-27":{"recorded_price":230.20},"2022-10-30":{"recorded_price":255.20}}}]

Query

db.collection.update({},[{$set:{datesArr:{$objectToArray:"$dates"}}},{$set:{datesArr:{$reduce:{input:"$datesArr",initialValue:{k:{$dateAdd:{startDate:"$$NOW",amount:-7,unit:"day"}},v:{recorded_price:{$max:"$datesArr.v.recorded_price"}}},in:{$cond:[{$and:[{$gte:[{$dateFromString:{"dateString":"$$this.k"}},"$$value.k"]},{$lte:["$$this.v.recorded_price","$$value.v.recorded_price"]}]},{k:{$dateFromString:{"dateString":"$$this.k"}},v:"$$this.v.recorded_price"},"$$value"]}}}}},{$set:{min_7day_price:"$datesArr.v",datesArr:"$$REMOVE"}}])

Result