- Jan 2, 2006
- 10,455
- 35
- 91
The MongoDB docs don't say what exactly a cursor *is*.
If I do the following:
db.users.find({age: 20})
I get a "cursor", which I'm then expected to "iterate" over. When I hear "iterate" I think "do something over and over" or "loop."
But if I do:
db.users.find({age: 20}).fetch()
I get an actual object containing all the keys and values matching my query.
So what exactly is a cursor? Is it like an address that points to the results of the query? How do you "iterate" over an address?
Cursors in Mongo deactivate themselves after 10 minutes. So I'm thinking that maybe cursors are, like, a set of instructions to find what I'm querying? It doesn't perform the actual query and it doesn't return the actual objects?
If I do the following:
db.users.find({age: 20})
I get a "cursor", which I'm then expected to "iterate" over. When I hear "iterate" I think "do something over and over" or "loop."
But if I do:
db.users.find({age: 20}).fetch()
I get an actual object containing all the keys and values matching my query.
So what exactly is a cursor? Is it like an address that points to the results of the query? How do you "iterate" over an address?
Cursors in Mongo deactivate themselves after 10 minutes. So I'm thinking that maybe cursors are, like, a set of instructions to find what I'm querying? It doesn't perform the actual query and it doesn't return the actual objects?