Document.prototype.$isDeleted()

Parameters
  • [val] «Boolean» optional, overrides whether mongoose thinks the doc is deleted
Returns:
  • «Boolean» whether mongoose thinks this doc is deleted.

Getter/setter, determines whether the document was removed or not.

Example:

  1. product.remove(function (err, product) {
  2. product.$isDeleted(); // true
  3. product.remove(); // no-op, doesn't send anything to the db
  4. product.$isDeleted(false);
  5. product.$isDeleted(); // false
  6. product.remove(); // will execute a remove against the db
  7. })