Document.prototype.execPopulate()

Parameters
  • [callback] «Function» optional callback. If specified, a promise will not be returned
Returns:
  • «Promise» promise that resolves to the document when population is done

Explicitly executes population and returns a promise. Useful for promises integration.

Example:

  1. const promise = doc.
  2. populate('company').
  3. populate({
  4. path: 'notes',
  5. match: /airline/,
  6. select: 'text',
  7. model: 'modelName'
  8. options: opts
  9. }).
  10. execPopulate();
  11. // summary
  12. doc.execPopulate().then(resolve, reject);

// you can also use doc.execPopulate(options) as a shorthand for // doc.populate(options).execPopulate()

Example:

const promise = doc.execPopulate({ path: ‘company’, select: ‘employees’ });

// summary promise.then(resolve,reject);