title: Insert into MongoDB via Node.js
body: <p>I am new to both Node.js and MongoDB, but I intend to create a very basic real time geolocation based web app. Here is my attempt at figuring out how Node and MongoDB interact:</p>
  
  <pre><code>var mongo = require('mongodb');
  
  var db = new mongo.Db('test', new mongo.Server('localhost',22892, {}), {});
  
  db.open(function(){});
  
  db.collection('docs', function(err,collection){
      doc = {"foo":"bar"};
      collection.insert(doc, function(){});
  });
  </code></pre>
  
  <p>I can see that this is connecting:</p>
  
  <pre><code>Thu Apr 14 15:24:12 [initandlisten] connection accepted from 127.0.0.1:46968 #26
  Thu Apr 14 15:24:12 [conn26] building new index on { _id: 1 } for test.docs
  Thu Apr 14 15:24:12 [conn26] done for 0 records 0secs
  </code></pre>
  
  <p>But it's not inserting any documents into the database. Can anyone tell me what I am doing wrong?</p>
  
  <p>Thanks</p>