Created
June 18, 2014 14:11
-
-
Save joshcanhelp/b4eebe3be32d46a648d9 to your computer and use it in GitHub Desktop.
Mongo 101 homework 2.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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