* Make sure `this` is a model * @api private
(ctx, fnName)
| 1059 | */ |
| 1060 | |
| 1061 | function _checkContext(ctx, fnName) { |
| 1062 | // Check context, because it is easy to mistakenly type |
| 1063 | // `new Model.discriminator()` and get an incomprehensible error |
| 1064 | if (ctx == null || ctx === global) { |
| 1065 | throw new MongooseError('`Model.' + fnName + '()` cannot run without a ' + |
| 1066 | 'model as `this`. Make sure you are calling `MyModel.' + fnName + '()` ' + |
| 1067 | 'where `MyModel` is a Mongoose model.'); |
| 1068 | } else if (ctx[modelSymbol] == null) { |
| 1069 | throw new MongooseError('`Model.' + fnName + '()` cannot run without a ' + |
| 1070 | 'model as `this`. Make sure you are not calling ' + |
| 1071 | '`new Model.' + fnName + '()`'); |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | // Model (class) features |
| 1076 |
no outgoing calls
no test coverage detected
searching dependent graphs…