In my current project, I am utilizing the mongojs
library and facing an issue while attempting to iterate through all elements in a collection.
index = 0
db.keys.find({}, {uid: 1, _id: 0}).forEach((err, key) =>
if err?
console.log err
else
console.log (++index) + " key: " + key_uid
This code snippet logs:
1 key: bB0KN
2 key: LOtOL
3 key: 51xJM
4 key: x9wFP
5 key: hcJKP
6 key: QZxnE
.
.
.
96 key: EeW6E
97 key: wqfmM
98 key: LIGHK
99 key: bjWTI
100 key: 2zNGE
101 key: F71mL
However, the logging stops prematurely. Upon checking from the terminal using MongoDB, the command
> db.keys.count()
2317381
reveals that there are significantly more keys in the database that should be returned. Any suggestions on what might be causing this unexpected behavior?