Database

[{"prop":{"nestedField":{nf2:"oldValue"/** Property to be updated*/}},"keyPath":"prop.nestedField.nf2",/** Path to the target field using dot notation*/"val":"newValue"/** New value to set to target field*/}]

Query

db.collection.update({},[{"$set":{"tokens":{"$reverseArray":{"$split":["$keyPath","."]}}}},{"$set":{"updateObject":{"$reduce":{"input":{"$slice":["$tokens",1,{"$size":"$tokens"}]},"initialValue":{"$arrayToObject":[[{k:{"$first":"$tokens"},v:"$val"}]]},"in":{"$arrayToObject":[[{k:"$$this",v:"$$value"}]]}}}}},{"$replaceWith":{"$mergeObjects":["$$ROOT","$updateObject"]}},{"$unset":["updateObject","tokens"]}])

Result