📜  跳过方法 js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:02.853000             🧑  作者: Mango

代码示例1
function printStudents(pageNumber, nPerPage) {
  print( "Page: " + pageNumber );
  db.students.find()
             .sort( { _id: 1 } )
             .skip( pageNumber > 0 ? ( ( pageNumber - 1 ) * nPerPage ) : 0 )
             .limit( nPerPage )
             .forEach( student => {
               print( student.name );
             } );
}