title: Mongodb fetch document by latest date in collection
body: <p>I'm new for mongodb, Developing node js application and using mongodb(Mongodb Server).And i have the one document in bellow structure</p>
  
  <pre><code>{ "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2816", "gold24ct10grm" : "281736", "silver1grm" : "47.30", "silver1kg" : "473580", "created" : "28-01-2014 07:56:14 am", "_id" : { "$oid" : "52e7629ec1a04e0000000001" } }
  { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2816", "gold24ct10grm" : "281736", "silver1grm" : "47.30", "silver1kg" : "473580", "created" : "28-01-2014 07:56:17 am", "_id" : { "$oid" : "52e762a1c1a04e0000000002" } }
  { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2861", "gold24ct10grm" : "28650", "silver1grm" : "48.36", "silver1kg" : "48756", "created" : "28-01-2014 08:09:40 am", "_id" : { "$oid" : "52e765c4683bee0000000001" } }
  { "associationid" : "52e75a9e0c504d0000000002", "gold22ct1grm" : "2865", "gold24ct10grm" : "28653", "silver1grm" : "45.50", "silver1kg" : "45655", "created" : "28-01-2014 11:10:16 am", "_id" : { "$oid" : "52e790182ffd050000000001" } }
  { "associationid" : "52e75a9e0c504d0000000002", "gold22ct1grm" : "2865", "gold24ct10grm" : "28653", "silver1grm" : "45.50", "silver1kg" : "45655", "created" : "28-01-2014 11:10:18 am", "_id" : { "$oid" : "52e7901a2ffd050000000002" } }
  { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2895", "gold24ct10grm" : "28950", "silver1grm" : "45.36", "silver1kg" : "45690", "created" : "30-01-2014 06:26:43 am", "_id" : { "$oid" : "52e9f0a35a72ac0000000001" } }
  { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2895", "gold24ct10grm" : "28950", "silver1grm" : "45.36", "silver1kg" : "45690", "created" : "30-01-2014 06:26:44 am", "_id" : { "$oid" : "52e9f0a45a72ac0000000002" } }
  { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2895", "gold24ct10grm" : "28950", "silver1grm" : "45.36", "silver1kg" : "45690", "created" : "30-01-2014 06:26:45 am", "_id" : { "$oid" : "52e9f0a55a72ac0000000003" } }
  { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2895", "gold24ct10grm" : "28950", "silver1grm" : "45.36", "silver1kg" : "45690", "created" : "30-01-2014 06:26:46 am", "_id" : { "$oid" : "52e9f0a65a72ac0000000004" } }
  { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2808", "gold24ct10grm" : "30030", "silver1grm" : "47.50", "silver1kg" : "44385", "created" : "30-01-2014 06:59:00 AM", "_id" : { "$oid" : "52e9f8343e49250000000001" } }
  { "associationid" : "52dbb5f4279f660000000002", "gold22ct1grm" : "2809", "gold24ct10grm" : "30033", "silver1grm" : "47.50", "silver1kg" : "44385", "created" : "30-01-2014 07:31:10 AM", "_id" : { "$oid" : "52e9ffbe51e5d90000000001" } }
  { "associationid" : "52dbb5f4279f660000000002", "gold22ct1grm" : "2810", "gold24ct10grm" : "30050", "silver1grm" : "48.50", "silver1kg" : "44385", "created" : "30-01-2014 01:09:40 PM", "_id" : { "$oid" : "52ea01bc7c64dd0000000001" } }
  { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2816", "gold24ct10grm" : "281736", "silver1grm" : "47.30", "silver1kg" : "473580", "created" : "11-02-2014 07:56:14 AM", "_id" : { "$oid" : "52e7629ec1a04e0000000001" } }
  
  How to get the document created finally.(most latest date created)
  I used following code in my node.js but it returning wrong answer
  exports.getMJDMADailyRates = function(id, callback)
  {
      associationrates.find({associationid : id}, {'limit':1, 'sort': { 'created' : -1 } }).toArray(function(err, docs) { 
          if(err) callback(err,null);
          else callback(null,docs);
      });
  }
  </code></pre>
  
  <p>If i call the function like getMJDMADailyRates('52dbb5c0279f660000000001'); means it should return bellow document</p>
  
  <pre><code> { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2816", "gold24ct10grm" : "281736", "silver1grm" : "47.30", "silver1kg" : "473580", "created" : "11-02-2014 07:56:14 AM", "_id" : { "$oid" : "52e7629ec1a04e0000000001" } }
  </code></pre>
  
  <p>but i'm getting like,</p>
  
  <pre><code>  { "associationid" : "52dbb5c0279f660000000001", "gold22ct1grm" : "2808", "gold24ct10grm" : "30030", "silver1grm" : "47.50", "silver1kg" : "44385", "created" : "30-01-2014 06:59:00 AM", "_id" : { "$oid" : "52e9f8343e49250000000001" } }
  </code></pre>
  
  <p>what is the mistake and how to get expected result by query.</p>