mongodb - Iterate over cursor with offset -


i have got following data:

{ _id: "aaa" } { _id: "aab" } { _id: "aav" } { _id: "baa" } { _id: "bac" } { _id: "bad" } 

i want cursor to, lets say, documents starting on b , iterate end.

pseudocode

cursor.offset(_id: "b").each{ |doc| puts doc } #=> { _id: "baa" } #=> { _id: "bac" } #=> { _id: "bad" } 

as far mongodb stores indexes in b-tree should possible somehow :)

just search documents >= "b":

db.collection.find( { _id: { $gte: "b" } } ); 

and iterate on result set.


Comments