Created
March 28, 2012 15:13
-
-
Save JanPaulEttles/2227066 to your computer and use it in GitHub Desktop.
jandefence3
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
| > var cursor = db.coll.find().sort({"someNumber":1}); | |
| > var max = -1; | |
| > var count = 0; | |
| > while(cursor.hasNext()) { | |
| ... count++; | |
| ... var current = cursor.next(); | |
| ... print(max + ' ' + current.someNumber); | |
| ... if(current.someNumber> max) { | |
| ... print(max + ' ' + current.someNumber); | |
| ... max = current.someNumber; | |
| ... } | |
| ... } | |
| -1 1 | |
| -1 1 | |
| 1 10 | |
| 1 10 | |
| 10 100 | |
| 10 100 | |
| 100 110 | |
| 100 110 | |
| 110 120 | |
| 110 120 | |
| 120 150 | |
| 120 150 | |
| 150 20 | |
| 150 20 | |
| 20 200 | |
| 20 200 | |
| 200 50 | |
| 200 50 | |
| 50 90 | |
| 50 90 | |
| 90 | |
| > print(max); | |
| 90 | |
| > print(count); | |
| 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment