0

Here is my collection:

{
    "_id" : ObjectId("58d32e3c8726e31b00004ac9"), 
    "buyer" : "zul@buyer1001", 
    "sellers" : [
        {
            "seller" : "razi@seller1001", 
            "items" : [
                {
                    "item_name" : "Mizuno Wave Lightning Z3", 
                    "brand" : "Mizuno",
                    "status" : "Disabled"
                },
                {
                    "item_name" : "Mizuno Wave Fang SS", 
                    "brand" : "Mizuno",
                    "status" : "Disabled"
                }
            ]
         }
    ]
}

How do I update all items status to "Enable" ?

1
  • Hi Adfued Fufu Fued, and welcome to Stack Overflow. Can you show what you've tried so far, and point out where it is working or not working? You shouldn't ask a question without showing some evidence that you've already tried to find out the answer for yourself. Commented Mar 23, 2017 at 10:37

1 Answer 1

0

For Mongo shell you can use this command,

db.collection.find({}).forEach(function(doc) {
doc.sellers.forEach(function(list) {
    list.items.forEach(function(object) {
        object.status = "Enabled";
    });
});
db.collection.save(doc);
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.