Skip to content

Commit

Permalink
fix(connection): clone schema when passing a schema from a different …
Browse files Browse the repository at this point in the history
…copy of Mongoose to `Connection#model()`

Fix #10904
  • Loading branch information
vkarpov15 committed Nov 17, 2021
1 parent 97434b8 commit f37577d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ Connection.prototype.model = function(name, schema, collection, options) {
schema = false;
}

if (utils.isObject(schema) && !schema.instanceOfSchema) {
if (utils.isObject(schema) && !(schema instanceof this.base.Schema)) {
schema = new Schema(schema);
}
if (schema && !schema.instanceOfSchema) {
Expand Down

0 comments on commit f37577d

Please sign in to comment.