Created
October 22, 2015 17:29
-
-
Save twinsdbv/0eda860d12b026aa8d47 to your computer and use it in GitHub Desktop.
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:27017/weather', function(err, db) { | |
if(err) throw err; | |
var cursor = db.collection('data').find().sort({'State': 1, 'Temperature': -1}).batchSize(5000); | |
var prevState = ''; | |
cursor.each(function(err, doc) { | |
if(err) throw err; | |
if(doc == null) { | |
return db.close(); | |
} | |
if (prevState != doc.State) { | |
console.log(prevState, doc.State); | |
db.collection('data').update({_id: doc._id}, {$set: {month_high: true}}); | |
console.log(doc); | |
} | |
prevState = doc.State; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment