From c5ecfd46e008733966ce2734680672112b100756 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Mon, 18 Dec 2017 15:37:40 -0800 Subject: [PATCH] fix: copy over hooks from base schema Re: Automattic/mongoose#5897 --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 16f84d4..cf9d898 100644 --- a/index.js +++ b/index.js @@ -2,10 +2,12 @@ const mongoose = require('mongoose'); function extendSchema (Schema, definition, options) { - return new mongoose.Schema( + var toReturn = new mongoose.Schema( Object.assign({}, Schema.obj, definition), options ); + toReturn.callQueue = [].concat(Schema.callQueue); // copy hooks + return toReturn; } module.exports = extendSchema;