title: Write concerns inserting document in mongodb native driver for node.js
body: <p>I'm having problems using write concerns with mongodb native driver for Node.js. I'm using a single MongoDB server in localhost. This is the code i'm using:</p>
  
  <pre><code>function insertNewDoc(newdoc, cbsuccess, cberror){
  
  db.collection('test').insert(newdoc, {w: 1, wtimeout: 2000}, function(err){
  if (err) cberror(err);
  else cbsuccess(newdoc);
  });
  
  }
  </code></pre>
  
  <p>I've tried to stop mongodb just before executing this function, but it keeps trying until mongo is on again, and then it inserts the document. What I want is to set a timeout so in case the document had not been successfully inserted after 2 seconds, it returns me an error.</p>