divergentArray.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*!
  2. * Module dependencies.
  3. */
  4. var MongooseError = require('../error.js');
  5. /*!
  6. * DivergentArrayError constructor.
  7. *
  8. * @inherits MongooseError
  9. */
  10. function DivergentArrayError (paths) {
  11. var msg = 'For your own good, using `document.save()` to update an array '
  12. + 'which was selected using an $elemMatch projection OR '
  13. + 'populated using skip, limit, query conditions, or exclusion of '
  14. + 'the _id field when the operation results in a $pop or $set of '
  15. + 'the entire array is not supported. The following '
  16. + 'path(s) would have been modified unsafely:\n'
  17. + ' ' + paths.join('\n ') + '\n'
  18. + 'Use Model.update() to update these arrays instead.'
  19. // TODO write up a docs page (FAQ) and link to it
  20. MongooseError.call(this, msg);
  21. Error.captureStackTrace && Error.captureStackTrace(this, arguments.callee);
  22. this.name = 'DivergentArrayError';
  23. };
  24. /*!
  25. * Inherits from MongooseError.
  26. */
  27. DivergentArrayError.prototype = Object.create(MongooseError.prototype);
  28. DivergentArrayError.prototype.constructor = MongooseError;
  29. /*!
  30. * exports
  31. */
  32. module.exports = DivergentArrayError;