Saturday 21 February 2015

mongoDB : skip number of documents in result


“skip” method is used to skip number of documents, while displaying the result.

> db.employee.find()
{ "_id" : ObjectId("54b348e01deb1f5f980626a2"), "id" : 1, "firstName" : "Joel", "lastName" : "chelli" }
{ "_id" : ObjectId("54b348e01deb1f5f980626a3"), "id" : 2, "firstName" : "Ananad", "lastName" : "Bandaru" }
{ "_id" : ObjectId("54b348e01deb1f5f980626a4"), "id" : 3, "firstName" : "Gopi", "lastName" : "Battu" }
{ "_id" : ObjectId("54b348e01deb1f5f980626a5"), "id" : 4, "firstName" : "Ritwik", "lastName" : "Mohenthy" }
>
>
> db.employee.find().skip(2)
{ "_id" : ObjectId("54b348e01deb1f5f980626a4"), "id" : 3, "firstName" : "Gopi", "lastName" : "Battu" }
{ "_id" : ObjectId("54b348e01deb1f5f980626a5"), "id" : 4, "firstName" : "Ritwik", "lastName" : "Mohenthy" }
>

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment