Wypróbuj to
db.collection.update(
{ _id : ObjectId("57315ba4846dd82425ca2408")},
{ $pull: {"myarray.userId": ObjectId("570ca5e48dbe673802c2d035")}}
)
db.collection.update(
{ _id : ObjectId("57315ba4846dd82425ca2408")},
{ $push: {"myarray": {
userId:ObjectId("570ca5e48dbe673802c2d035"),
point: 10
}}
)
Wyjaśnienie:w pierwszym wyciągu $pull
usuwa element z userId= ObjectId("570ca5e48dbe673802c2d035")
z tablicy w dokumencie, gdzie _id = ObjectId("57315ba4846dd82425ca2408")
W drugim $push
wstawia ten obiekt { userId:ObjectId("570ca5e48dbe673802c2d035"), point: 10 }
w tej samej tablicy.