MongoDB skip() Method
Use skip() method to skip a number of documents. It works MongoDB find() method.
Syntax:
db.COLLECTION_NAME.find().limit(NUMBER).skip(NUMBER)
Example
For example you have 10 documents you collection users. Now get the 2 documents after 5 documents. Like you need to get 6’th and 7’th documents from the collection.
db.users.find().limit(2).skip(5)
The above query will skin first 5 documents from the collection and then show 2 documents.
Output:
{ "_id" : ObjectId("59a01c912427abe3470644de"), "id" : 1006, "user_name" : "peter", "name" : [ { "first_name" : "Peter" }, { "middle_name" : "S" }, { "last_name" : "Jaction" } ], "email" : "[email protected]", "designation" : "Director", "location" : "California" } { "_id" : ObjectId("59a01c912427abe3470644df"), "id" : 1007, "user_name" : "marc", "name" : [ { "first_name" : "Marc" }, { "middle_name" : "" }, { "last_name" : "Di" } ], "email" : "[email protected]", "designation" : "Sr Analyst", "location" : "Australia" }