I am new to mongo now I trying to do in MongoDB push and pull query concept in the array. I want to pull all object and push the new object into an array while using pull alone its working fine and same push alone working fine but i used both in single query i tired but not able to achieve my need help to solve this Note:UIList array is Dynamic
My Query
db.getCollection('roles').update(
{ "_id": ObjectId("5bd6b1dc552a2a3ed0bde948") },
{ "$pull": { "UIList": { } } },
{ "$push": {$set: "UIList": { "field1": "1234", "field2": "12345" } } }) //Not working