bguerout/jongo

How to query?

Closed this issue · 1 comments

{
"_id" : ObjectId("4faaba123412d654fe83hg876"),
"user_id" : 123456,
"total" : 100,
"items" : [
{
"item_name" : "my_item_one",
"price" : 20
},
{
"item_name" : "my_item_two",
"price" : 50
},
{
"item_name" : "my_item_three",
"price" : 30
}
]
}

  • I want to increase the price for "item_name":"my_item_two" and if it doesn't exists, it should be appended to the "items" array.
    With mongode query is:
    db.bar.update( {user_id : 123456 , "items.item_name" : "my_item_two" } ,
    {$inc : {"items.$.price" : 1} } ,
    false ,
    true);
    Please help me, Thanks

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.