Query.prototype.getPopulatedPaths()

Returns:
  • «Array» an array of strings representing populated paths

Gets a list of paths to be populated by this query

Example:

  1. bookSchema.pre('findOne', function() {
  2. let keys = this.getPopulatedPaths(); // ['author']
  3. });
  4. ...
  5. Book.findOne({}).populate('author');

Example:

  1. // Deep populate
  2. const q = L1.find().populate({
  3. path: 'level2',
  4. populate: { path: 'level3' }
  5. });
  6. q.getPopulatedPaths(); // ['level2', 'level2.level3']