Document.prototype.depopulate()

Parameters
  • path «String»
Returns:
  • «Document» this

Takes a populated field and returns it to its unpopulated state.

Example:

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

If the path was not populated, this is a no-op.