Database
[{"name":"myname","field1":[{"userId":"customerId","field2":["a","b"]},{"userId":"customerId2","field2":["a","b"]}]},{"name":"myname2","field1":[{"userId":"customerId","field2":["a","b"]}]}]
Query
db.collection.aggregate([{$match:{name:"myname"}},{$set:{field1:{$map:{input:"$field1",in:{$cond:{if:{$ne:["$$this.userId","customerId"]},then:"$$this",else:{$mergeObjects:["$$this",{field2:{$concatArrays:[{$slice:["$$this.field2",{$add:[{$size:"$$this.field2"},-1]}]},["value"]]}}]}}}}}}}])