Document.prototype.populated()

Parameters
  • path «String»
Returns:
  • «Array,ObjectId,Number,Buffer,String,undefined»

Gets _id(s) used during population of the given path.

Example:

  1. Model.findOne().populate('author').exec(function (err, doc) {
  2. console.log(doc.author.name) // Dr.Seuss
  3. console.log(doc.populated('author')) // '5144cf8050f071d979c118a7'
  4. })

If the path was not populated, returns undefined.