Skip to content

Commit

Permalink
fix(model): throw sane error when customer calls mongoose.Model() o…
Browse files Browse the repository at this point in the history
…ver `mongoose.model()`

Fix #2005
  • Loading branch information
vkarpov15 committed Oct 24, 2017
1 parent cf8ef5f commit 5d9c858
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ var VERSION_WHERE = 1,
*/

function Model(doc, fields, skipId) {
if (fields instanceof Schema) {
throw new TypeError('2nd argument to `Model` must be a POJO or string, ' +
'**not** a schema. Make sure you\'re calling `mongoose.model()`, not ' +
'`mongoose.Model()`.');
}
Document.call(this, doc, fields, skipId, true);
}

Expand Down

0 comments on commit 5d9c858

Please sign in to comment.