Skip to content

Instantly share code, notes, and snippets.

@joshcanhelp
Created June 18, 2014 14:11
Show Gist options
  • Save joshcanhelp/b4eebe3be32d46a648d9 to your computer and use it in GitHub Desktop.
Save joshcanhelp/b4eebe3be32d46a648d9 to your computer and use it in GitHub Desktop.
Mongo 101 homework 2.2
var MongoClient = require('mongodb').MongoClient;
MongoClient.connect('mongodb://localhost/m101', function(err, db) {
if (err) {
throw err;
}
var data = db.collection('data');
var cursor = data.find({});
cursor.sort("Temperature", -1);
cursor.each(function (err, doc) {
if (err) {
throw err;
}
if (doc === null) {
db.close();
}
console.log(doc);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment