Mongo db更新数组对象

时间:2016-09-13 05:23:42

标签: arrays

{  
    "_id" : ObjectId("4faaba123412d654fe83hg876"),  
    "user_id" : 123456,  
    "total" : 100,  
    "items" : [  
            { "item_name" : "my_item_one",  
               "price" : 20,  
             "veriety":
             [{  
            color:"red",  
            make:"plastic"  
             },{color:"green",  
            make:"metal" 
        }]  
            },  
            {  
                    "item_name" : "my_item_two",  
                    "price" : 50,  
        "veriety":[  
        {  
            color:"red",  
            make:"plastic"  
        }  
        ]  
            },  
            {  
                    "item_name" : "my_item_three",  
                    "price" : 30,  
        "veriety":[  
            {  
            color:"red",  
            make:"plastic"  
           }  
         ]  
            }  
    ]  
}  

在这种情况下,我想更新价格为30且“总数”为100的颜色,......我该怎么办?

0 个答案:

没有答案