How do you pass variables into MongoDB via node-mongo-native?

I need to find a doc and set its sub object to 3.

{
  doc_id = 'dock_id1',
  update = events{a:{b:3}}
}

How do I pass this into a node-mongo-native query to set events.a.b = 3 on the doc with the id doc_id1?

I don't mean setting events.a.b every time. I mean passing in a variable from that object in a way that I could get a new object with new data and apply it the same way.

Thanks!

You can either pass an object literal:

  collection.insert( { foo: 'bar' }, function( error, documents ) { console.log( 'error', error, 'documents', documents ) } );

.. or pass an existing object:

  var obj = { foo: 'bar' };
  collection.insert( obj, function( error, documents ) { console.log( 'error', error, 'documents', documents ) } );

If you're trying to create an object, this is not correct syntax:

events{a:{b:3}}