0

I have collection, contain an array of objects and I want to delete one object by filter inside this array example:

"ProductsImages" : [
    {
        "_id" : ObjectId("5c6fc524c324ac0e7497b6c0"), 
        "Namefile" : "Bild-4.png", 
        "Urls" : "https://fares.blob.core.windows.net/fares2/Bild-4.png"
    }, 
    {
        "_id" : ObjectId("5c6fc52cc324ac0e7497b6c1"), 
        "Namefile" : "KINGSTON-BAY-704668-logo.png", 
        "Urls" : "https://fares.blob.core.windows.net/fares2/KINGSTON-BAY-704668-logo.png"
    }
],

so i want to delete first one which contain a "Namefile" : "Bild-4.png" in mongodb shell, or C# monogodb drive and thanks for your help.

2

1 Answer 1

1

Please try this update query

db.collName.update({"ProductsImages.Namefile": "Bild-4.png"},{$pull: {"ProductsImages": {"Namefile": "Bild-4.png"}}})

Note: Update the first filter condition as required

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.