How to change value?

If you want to modify more than a single element, you simply need multiple arrayFilters, one for each element you want to modify. If I understand your situation correctly you may try the following untested code to see if it works.

uid_1 = 1000
count_1 = 777
uid_2 = 2000
count_2 = 888
db.nonames.updateOne(
    { "_id" : 1 } ,
    { "$set" : {
        "skills.$[one].count" : count_1 ,
        "skills.$[two].count" : count_2
    } } ,
    { "arrayFilters" : [
        { "one.uid" : uid_1 } ,
        { "two.uid" : uid_2 }
    ] }
) ;

While at it, could you please provide followup and potential mark as solve your thread

2 Likes