/node_modules/mongoose/lib/error/divergentArray.js

https://bitbucket.org/coleman333/smartsite · JavaScript · 46 lines · 21 code · 10 blank · 15 comment · 2 complexity · c70e4f9e749f4af386ca591b5c5bc777 MD5 · raw file

  1. /*!
  2. * Module dependencies.
  3. */
  4. var MongooseError = require('./');
  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. this.name = 'DivergentArrayError';
  22. if (Error.captureStackTrace) {
  23. Error.captureStackTrace(this);
  24. } else {
  25. this.stack = new Error().stack;
  26. }
  27. }
  28. /*!
  29. * Inherits from MongooseError.
  30. */
  31. DivergentArrayError.prototype = Object.create(MongooseError.prototype);
  32. DivergentArrayError.prototype.constructor = MongooseError;
  33. /*!
  34. * exports
  35. */
  36. module.exports = DivergentArrayError;