lib/operations/collection_ops.js
function parallelCollectionScan(coll, options, callback) {
  // Create command object
  const commandObject = {
    parallelCollectionScan: coll.s.name,
    numCursors: options.numCursors
  };

  // Do we have a readConcern specified
  decorateWithReadConcern(commandObject, coll, options);

  // Store the raw value
  const raw = options.raw;
  delete options['raw'];

  // Execute the command
  executeCommand(coll.s.db, commandObject, options, (err, result) => {
    if (err) return handleCallback(callback, err, null);
    if (result == null)
      return handleCallback(
        callback,
        new Error('no result returned for parallelCollectionScan'),
        null
      );

    options = Object.assign({ explicitlyIgnoreSession: true }, options);

    const cursors = [];
    // Add the raw back to the option
    if (raw) options.raw = raw;
    // Create command cursors for each item
    for (let i = 0; i < result.cursors.length; i++) {
      const rawId = result.cursors[i].cursor.id;
      // Convert cursorId to Long if needed
      const cursorId = typeof rawId === 'number' ? Long.fromNumber(rawId) : rawId;
      // Add a command cursor
      cursors.push(coll.s.topology.cursor(coll.s.namespace, cursorId, options));
    }

    handleCallback(callback, null, cursors);
  });
}
function parallelCollectionScan(coll, options, callback) {
  // Create command object
  const commandObject = {
    parallelCollectionScan: coll.s.name,
    numCursors: options.numCursors
  };

  // Do we have a readConcern specified
  decorateWithReadConcern(commandObject, coll, options);

  // Store the raw value
  const raw = options.raw;
  delete options['raw'];

  // Execute the command
  executeCommand(coll.s.db, commandObject, options, (err, result) => {
    if (err) return handleCallback(callback, err, null);
    if (result == null)
      return handleCallback(
        callback,
        new Error('no result returned for parallelCollectionScan'),
        null
      );

    options = Object.assign({ explicitlyIgnoreSession: true }, options);

    const cursors = [];
    // Add the raw back to the option
    if (raw) options.raw = raw;
    // Create command cursors for each item
    for (let i = 0; i < result.cursors.length; i++) {
      const rawId = result.cursors[i].cursor.id;
      // Convert cursorId to Long if needed
      const cursorId = typeof rawId === 'number' ? Long.fromNumber(rawId) : rawId;
      // Add a command cursor
      cursors.push(coll.s.topology.cursor(coll.s.namespace, cursorId, options));
    }

    handleCallback(callback, null, cursors);
  });
}
function parallelCollectionScan ( coll , options , callback ) { // Create command object const commandObject = { parallelCollectionScan : coll . s . name , numCursors : options . numCursors } ; // Do we have a readConcern specified decorateWithReadConcern ( commandObject , coll , options ) ; // Store the raw value const raw = options . raw ; delete options [ 'raw' ] ; // Execute the command executeCommand ( coll . s . db , commandObject , options , ( err , result ) => { if ( err ) return handleCallback ( callback , err , null ) ; if ( result == null ) return handleCallback ( callback , new Error ( 'no result returned for parallelCollectionScan' ) , null ) ; options = Object . assign ( { explicitlyIgnoreSession : true } , options ) ; const cursors = [ ] ; // Add the raw back to the option if ( raw ) options . raw = raw ; // Create command cursors for each item for ( let i = 0 ; i < result . cursors . length ; i ++ ) { const rawId = result . cursors [ i ] . cursor . id ; // Convert cursorId to Long if needed const cursorId = typeof rawId === 'number' ? Long . fromNumber ( rawId ) : rawId ; // Add a command cursor cursors . push ( coll . s . topology . cursor ( coll . s . namespace , cursorId , options ) ) ; } handleCallback ( callback , null , cursors ) ; } ) ; }
Return N parallel cursors for a collection to allow parallel reading of the entire collection. There are
no ordering guarantees for returned results.

@method
@param {Collection} a Collection instance.
@param {object} [options] Optional settings. See Collection.prototype.parallelCollectionScan for a list of options.
@param {Collection~parallelCollectionScanCallback} [callback] The command result callback
Return N parallel cursors for a collection to allow parallel reading of the entire collection . There are no ordering guarantees for returned results .