Database

[{"_id":{"$oid":"62c40373d08fcf4ca03eb4b4"},"instrument_name":"BTCBUSD","exchangeType":"BINANCE","dt":1657005300000,"o":"20264.80000000","h":"20290.73000000","l":"20178.66000000","c":"20211.63000000"},{"_id":{"$oid":"62c40373d08fcf4ca03eb4b5"},"instrument_name":"BTCBUSD","exchangeType":"BINANCE","dt":1657006200000,"o":"20213.33000000","h":"20218.26000000","l":"20155.26000000","c":"20202.61000000"},{"_id":{"$oid":"62c40373d08fcf4ca03eb4b6"},"instrument_name":"BTCBUSD","exchangeType":"BINANCE","dt":1657007100000,"o":"20202.61000000","h":"20238.23000000","l":"20172.76000000","c":"20192.74000000"},{"_id":{"$oid":"62c40373d08fcf4ca03eb4b7"},"instrument_name":"BTCBUSD","exchangeType":"BINANCE","dt":1657008000000,"o":"20192.75000000","h":"20192.75000000","l":"20033.95000000","c":"20090.00000000"},{"_id":{"$oid":"62c40373d08fcf4ca03eb4b8"},"instrument_name":"BTCBUSD","exchangeType":"BINANCE","dt":1657008900000,"o":"20090.00000000","h":"20098.49000000","l":"19930.00000000","c":"19989.98000000"}]

Query

db.collection.aggregate([{$match:{instrument_name:"BTCBUSD",exchangeType:"BINANCE"}},{$facet:{found:[{$match:{dt:1657008000001}},{$set:{c:24}}],notFound:[{$match:{dt:{$lt:1657008000001}}},{$limit:1},]}},{$set:{found:{$first:"$found"},notFound:{$mergeObjects:[{$first:"$notFound"},{c:7,o:19}]}}},{$project:{newObj:{$ifNull:["$found","$notFound"]}}},{$merge:{into:"collection"}}])

Result