mongodb big data paging

// Get the first page of data

var page = db.test.find().sort({"_id":1}).limit(20);

var last;

// Determine whether there is the next page of data

while( page.hasNext() ){

    latest = page.next();

}

 // Query the data of the next page

db.test.find({"_id": {"$gt": latest._id}  }).sort({"_id":1}).limit(20);

db.test.find({ "_id":{"$gt":ObjectId("6065b8940969d7a5ec042588")}  })  

Guess you like

Origin blog.51cto.com/1929297/2679876