Current location - Loan Platform Complete Network - Big data management - How to implement MongoDB paging query in Java
How to implement MongoDB paging query in Java

int index=0;

while(cursor.hasNext()&index

int i = limit-index;

//The query results are put into the collection list, and the last 10 items of the query results are taken.

if(i<10){

//Record the time of the first data on each page

if(i==9){

fistTime = db.get("time").toString();

}

//Record the time of the last piece of data on each page

if(i==0){

lastTime = db.get("time").toString();

}

list.add( cursor.hasNext().next());

}//end if

index++;

}//end while