I have a document schema in Mongodb that looks like this:
{ _id: 1 tags: [{ tag: \'foo\' links: [{ link: \'http:www.googl
Perhaps change your first query to:
db.userlinks.update ( {_id: 1, tags: {$nin: [{tag:'foo'}]}}, {$push: {'tags': {tag:'foo', links:[]}}}, {upsert: true} )
The $push operation should only affect links, not the tag.
{$push: {'tags.links': {link: 'http://www.google.com', date: '123'} } },