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