How can I delete nested array element in a mongodb document with the c# driver

前端 未结 6 1740
没有蜡笔的小新
没有蜡笔的小新 2021-02-14 08:21

I am new in the MongoDB world and now I am struggling of how can I delete, update element in a nested array field of a document. Here is my sample document:

{
           


        
6条回答
  •  生来不讨喜
    2021-02-14 08:51

    Hi as per my understanding you want to remove whole matched elements of given id and identifier so below query will solve your problem but I don't know how to convert this into C#, here mongo $pull method used.

    db.collectionName.update({"_id" : ObjectId("55f354533dd61e5004ca5208")}, {"$pull":{"Products":{"Identifier":"170220151653"}}})
    

提交回复
热议问题