How to fetch between a range of indexes in mongodb? -
i need help.. there method available fetch documents between range of indexes while using find in mongo.. [2:10] (from 2 10) ?
if talking "index" position within array in document want $slice operator. first argument being index start , second how many return. 0 index position 2 "third" index:
db.collection.find({},{ "list": { "$slice": [ 2, 8 ] }) within collection if use .limit() .skip() modifiers move through range in collection:
db.collection.find({}).skip(2).limit(8) keep in mind in collection context mongodb has no concept of "ordered" records , dependent on query and/or sort order given
Comments
Post a Comment