Skip to content

Commit

Permalink
fix(schema): make Schema#clone() use parent Mongoose instance's Sch…
Browse files Browse the repository at this point in the history
…ema constructor

Fix #9426
  • Loading branch information
vkarpov15 committed Sep 22, 2020
1 parent 40d408e commit 2007bc7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ Schema.prototype.tree;
*/

Schema.prototype.clone = function() {
const s = new Schema({}, this._userProvidedOptions);
const Constructor = this.base == null ? Schema : this.base.Schema;

const s = new Constructor({}, this._userProvidedOptions);
s.base = this.base;
s.obj = this.obj;
s.options = utils.clone(this.options);
Expand Down

0 comments on commit 2007bc7

Please sign in to comment.