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

43 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2014-09-14 07:04:16 -04:00
/*!
* Module dependencies.
*/
2015-11-24 22:08:58 -08:00
var MongooseError = require('../error.js');
2014-09-14 07:04:16 -04:00
/*!
* DivergentArrayError constructor.
*
* @inherits MongooseError
*/
2015-11-24 22:08:58 -08:00
function DivergentArrayError(paths) {
2014-09-14 07:04:16 -04:00
var msg = 'For your own good, using `document.save()` to update an array '
+ 'which was selected using an $elemMatch projection OR '
+ 'populated using skip, limit, query conditions, or exclusion of '
+ 'the _id field when the operation results in a $pop or $set of '
+ 'the entire array is not supported. The following '
+ 'path(s) would have been modified unsafely:\n'
+ ' ' + paths.join('\n ') + '\n'
2015-11-24 22:08:58 -08:00
+ 'Use Model.update() to update these arrays instead.';
2014-09-14 07:04:16 -04:00
// TODO write up a docs page (FAQ) and link to it
MongooseError.call(this, msg);
2015-11-24 22:08:58 -08:00
Error.captureStackTrace && Error.captureStackTrace(this, arguments.callee);
2014-09-14 07:04:16 -04:00
this.name = 'DivergentArrayError';
2015-11-24 22:08:58 -08:00
}
2014-09-14 07:04:16 -04:00
/*!
* Inherits from MongooseError.
*/
2015-11-24 22:08:58 -08:00
DivergentArrayError.prototype = Object.create(MongooseError.prototype);
DivergentArrayError.prototype.constructor = MongooseError;
2014-09-14 07:04:16 -04:00
/*!
* exports
*/
module.exports = DivergentArrayError;