divergentArray.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*!
  2. * Module dependencies.
  3. */
  4. 'use strict';
  5. const MongooseError = require('./');
  6. class DivergentArrayError extends MongooseError {
  7. /*!
  8. * DivergentArrayError constructor.
  9. * @param {Array<String>} paths
  10. */
  11. constructor(paths) {
  12. const msg = 'For your own good, using `document.save()` to update an array '
  13. + 'which was selected using an $elemMatch projection OR '
  14. + 'populated using skip, limit, query conditions, or exclusion of '
  15. + 'the _id field when the operation results in a $pop or $set of '
  16. + 'the entire array is not supported. The following '
  17. + 'path(s) would have been modified unsafely:\n'
  18. + ' ' + paths.join('\n ') + '\n'
  19. + 'Use Model.update() to update these arrays instead.';
  20. // TODO write up a docs page (FAQ) and link to it
  21. super(msg);
  22. }
  23. }
  24. Object.defineProperty(DivergentArrayError.prototype, 'name', {
  25. value: 'DivergentArrayError'
  26. });
  27. /*!
  28. * exports
  29. */
  30. module.exports = DivergentArrayError;