lib/mongodb/mongodb/lib/operations/cursor_ops.js
function nextObject(cursor, callback) {
  const Cursor = require('../cursor');

  if (cursor.s.state === Cursor.CLOSED || (cursor.isDead && cursor.isDead()))
    return handleCallback(
      callback,
      MongoError.create({ message: 'Cursor is closed', driver: true })
    );
  if (cursor.s.state === Cursor.INIT && cursor.s.cmd.sort) {
    try {
      cursor.s.cmd.sort = formattedOrderClause(cursor.s.cmd.sort);
    } catch (err) {
      return handleCallback(callback, err);
    }
  }

  // Get the next object
  cursor._next((err, doc) => {
    cursor.s.state = Cursor.OPEN;
    if (err) return handleCallback(callback, err);
    handleCallback(callback, null, doc);
  });
}
function nextObject(cursor, callback) {
  const Cursor = require('../cursor');

  if (cursor.s.state === Cursor.CLOSED || (cursor.isDead && cursor.isDead()))
    return handleCallback(
      callback,
      MongoError.create({ message: 'Cursor is closed', driver: true })
    );
  if (cursor.s.state === Cursor.INIT && cursor.s.cmd.sort) {
    try {
      cursor.s.cmd.sort = formattedOrderClause(cursor.s.cmd.sort);
    } catch (err) {
      return handleCallback(callback, err);
    }
  }

  // Get the next object
  cursor._next((err, doc) => {
    cursor.s.state = Cursor.OPEN;
    if (err) return handleCallback(callback, err);
    handleCallback(callback, null, doc);
  });
}
function nextObject ( cursor , callback ) { const Cursor = require ( '../cursor' ) ; if ( cursor . s . state === Cursor . CLOSED || ( cursor . isDead && cursor . isDead ( ) ) ) return handleCallback ( callback , MongoError . create ( { message : 'Cursor is closed' , driver : true } ) ) ; if ( cursor . s . state === Cursor . INIT && cursor . s . cmd . sort ) { try { cursor . s . cmd . sort = formattedOrderClause ( cursor . s . cmd . sort ) ; } catch ( err ) { return handleCallback ( callback , err ) ; } } // Get the next object cursor . _next ( ( err , doc ) => { cursor . s . state = Cursor . OPEN ; if ( err ) return handleCallback ( callback , err ) ; handleCallback ( callback , null , doc ) ; } ) ; }
Get the next available document from the cursor, returns null if no more documents are available.
Get the next available document from the cursor returns null if no more documents are available .