Created
December 29, 2011 22:56
-
-
Save develop7/1536576 to your computer and use it in GitHub Desktop.
Thing I've learned today
This file contains hidden or 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
// way to shoot your own leg | |
var q = db.some_collection.find({something: "awful"}); | |
q.forEach(function(o) {print(o.foo)}) //this will print something affects map() too | |
q.forEach(function(o) {print(o.bar)}) //will print nothing | |
/* because */ q.hasNext() // == false after first call | |
//right way is to reassign q or don't use it at all | |
db.some_collection.find({something: "awful"}).forEach(function(o) {print(o.foo)}) //will work | |
db.some_collection.find({something: "awful"}).forEach(function(o) {print(o.bar)}) //will print stuff too |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment