6. Using $SLICE
Get the last three comments
> db.user.findOne({}, , {“remarks" :
{"$slice" : -3}}
Get the first three comments
> db.user.findOne({}, , {“remarks" :
{"$slice" : 3}}
7. CURSOR
SIMILAR to implicit cursor in Oracle, give a
refrence pointer to the results untill fetch
the result will not be stored in the memory
For example : --
> var cursor = db.user.find()
> cursor.forEach(function(x) { print(x._id) } )
ObjectId("513c6ef1cfce9090d3fd8b1d")
ObjectId("513e1339cb4ee0901c14db28")
ObjectId("513e1340cb4ee0901c14db29")