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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -