Database
[{_id:1,age:"old",hobby:[{vehicle:"car",velocity:"fast"},{vehicle:"motorcycle",velocity:"fast"}]},{_id:2,age:"young"/** no hobby set*/},{_id:3,age:"young",/** hobby is null*/hobby:null},{_id:4,age:"young",/** hobby is empty array*/hobby:[]}]
Query
db.collection.update({/** uncomment this _id match for actual use*_id: 1*/},[{$set:{"age":"old","hobby":{$ifNull:[/** set the first object's velocity to slow* if it doesn't exist, or is null, or is an empty array* then this will be null and use the fallback expression*/{$concatArrays:[[{$mergeObjects:[{$arrayElemAt:["$hobby",0]},/** set velocity to slow for the first object*/{"velocity":"slow"}]}],{$slice:["$hobby",1,{/** use size=1 when hobby is an empty array []*/$max:[{$size:"$hobby"},1]}]}]},/** new hobby when missing*/[{"velocity":"slow"}]]}}}],{/** only for demo on playground* this is not needed in actual use* since _id match will only match one doc*/multi:true})