

db.userdata.update({_id:'PBYsgwCsTpdf7f9wp','chefAvailabilityDinner.id':'2014-11-15'},{$set:{'chefAvailabilityDinner.$.title':'BOOKED','chefAvailabilityDinner.$.eventid':'12345','chefAvailabilityDinner.$.allDay':false,'chefAvailabilityDinner.$.start':'2014-11-15T20:00:00','chefAvailabilityDinner.$.end':'2014-11-16T01:00:00','chefAvailabilityDinner.$.color':'#FF3300'}})

{ "_id" : "QRpW8k8ybTFSuLe24", "dishes" :
[
{"dishId" : "QZDYryAhhf9DcSigT","dishCategory" : "P6KsNgqhEAeZj84Sa","dishCategoryOriginal" : "P6KsNgqhEAeZj84Sa" },{"dishId" : "DhBafCiWLnFs9W6pf","dishCategory" : "LjoXyWfouCytSxXhQ","dishCategoryOriginal" : "LjoXyWfouCytSxXhQ" },{"dishId" : "YtrT5KiGNTmtGhoxi","dishCategory" : "P6KsNgqhEAeZj84Sa","dishCategoryOriginal" : "P6KsNgqhEAeZj84Sa" }
],
}

{ "_id" : "QRpW8k8ybTFSuLe24", "dishCategories" :
[
{"dishId" : "QZDYryAhhf9DcSigT","dishCategory" : "P6KsNgqhEAeZj84Sa","dishCategoryOriginal" : "P6KsNgqhEAeZj84Sa" },{"dishId" : "DhBafCiWLnFs9W6pf","dishCategory" : "LjoXyWfouCytSxXhQ","dishCategoryOriginal" : "LjoXyWfouCytSxXhQ" },{"dishId" : "YtrT5KiGNTmtGhoxi","dishCategory" : "P6KsNgqhEAeZj84Sa","dishCategoryOriginal" : "P6KsNgqhEAeZj84Sa" }
],
}

{"_id" : "QRpW8k8ybTFSuLe2a",
"dishCategories" : ["dishCategory": "123456", "dishes" : [{"dishId": "12345", "dishId": "12345"}]]
}

db.menus.insert({"_id" : "QRpW8k8ybTFSuLe2a","dishCategories" : ["dishCategory": "123456", "dishes" : [{"dishId": "12345"}, {"dishId": "512345"}]]})

db.menus.insert(
{
"_id" : "QRpW8k8ybTFSuLe2a","dishCategories" :
 [
 {
 "dishCategory": "22123456", "dishes" : [{"dishId": "12345"}, {"dishId": "55555"}]
 },
 {
  "dishCategory": "zzzzzz", "dishes" : [{"dishId": "aaaaa"}, {"dishId": "bbbb"}]
  }
 ]
}
)

Menus.insert(
{
'dishCategories' :
 [
 {
 'dishCategoryId': '22123456', 'dishes' : [{'dishId': '12345'}, {'dishId': '55555'}]
 },
 {
  'dishCategoryId': 'zzzzzz', 'dishes' : [{'dishId': 'aaaaa'}, {'dishId': 'bbbb'}]
  }
 ]
}
)

Menus.update({_id: e.added.id},{$push: {dishCategories:{dishCategoryId: categoryId}}});

Menus.update({_id: 'oBkFX86uC2mxpbFRo'},{$push: {dishCategories:{dishCategoryId: 'P6KsNgqhEAeZj84Sa' : {dishId: 'QZDYryAhhf9DcSigT'}}}})

Menus.update({_id: 'oBkFX86uC2mxpbFRo'},{$push: {dishCategories:{dishCategoryId: categoryId}}});

Menus.update({_id: 'oBkFX86uC2mxpbFRo'},{$push: {dishCategories.$.dishCategoryId{dishCategoryId: categoryId}}});


Menus.update({_id: 'avXYyFyGrcxkT9jMs'}, {$push: {dishes : {dish: 513210, dishCategory: 54321}}})
//from http://stackoverflow.com/questions/18600791/mongodb-update-array-element
----
db.test.update({
    "Fields.Field": "Lot No"
}, {
    $addToSet: {
        "Fields.$.Rules": {
            'item_name': "my_item_two",
            'price':1
        }
    }
}, false, true);
-----
--------
Menus.update({_id: 'avXYyFyGrcxkT9jMs',
    'dishCategories.dishCategoryId': 'P6KsNgqhEAeZj84Sa'
}, {
    $addToSet: {
        'dishCategories.$.dishes': {
            'dishId': 'QZDYryAhhf9DcSigT'
        }
    }
}, false, true);
--------
Menus.update({_id: 'bq7qzghWi6TKYeBLs',
    'dishCategories.dishCategoryId': 'P6KsNgqhEAeZj84Sa'
}, {
    $addToSet: {
        'dishCategories.$.dishes': {
            'dishId': 'QZDYryAhhf9DcSigT'
        }
    }
}, false, true);