compare value inside object and push object inside array mongodb code example
Example: insert item into list mongodb
db.col.update(
{ name: 'doc', 'list.id': 2 },
{$push: {'list.$.items': {id: 5, name: 'item5'}}}
)
db.col.update(
{ name: 'doc', 'list.id': 2 },
{$push: {'list.$.items': {id: 5, name: 'item5'}}}
)