divergentArray.js 1.1 KB

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