diff --git a/lib/options/SchemaDocumentArrayOptions.js b/lib/options/SchemaDocumentArrayOptions.js index 0a17a87e5e4..2283616388c 100644 --- a/lib/options/SchemaDocumentArrayOptions.js +++ b/lib/options/SchemaDocumentArrayOptions.js @@ -22,9 +22,9 @@ const opts = require('./propertyOptions'); /** * If `true`, Mongoose will skip building any indexes defined in this array's schema. * If not set, Mongoose will build all indexes defined in this array's schema. - * + * * ####Example: - * + * * const childSchema = Schema({ name: { type: String, index: true } }); * // If `excludeIndexes` is `true`, Mongoose will skip building an index * // on `arr.name`. Otherwise, Mongoose will build an index on `arr.name`. @@ -45,4 +45,4 @@ Object.defineProperty(SchemaDocumentArrayOptions.prototype, 'excludeIndexes', op * ignore */ -module.exports = SchemaArrayOptions; \ No newline at end of file +module.exports = SchemaDocumentArrayOptions; \ No newline at end of file diff --git a/lib/schema/documentarray.js b/lib/schema/documentarray.js index 9d95f2727a4..c7c179e830b 100644 --- a/lib/schema/documentarray.js +++ b/lib/schema/documentarray.js @@ -7,6 +7,8 @@ const ArrayType = require('./array'); const CastError = require('../error/cast'); const EventEmitter = require('events').EventEmitter; +const SchemaDocumentArrayOptions = + require('../options/SchemaDocumentArrayOptions'); const SchemaType = require('../schematype'); const discriminator = require('../helpers/model/discriminator'); const get = require('../helpers/get'); @@ -91,6 +93,7 @@ DocumentArrayPath.options = { castNonArrays: true }; */ DocumentArrayPath.prototype = Object.create(ArrayType.prototype); DocumentArrayPath.prototype.constructor = DocumentArrayPath; +DocumentArrayPath.prototype.OptionsConstructor = SchemaDocumentArrayOptions; /*! * Ignore diff --git a/test/model.indexes.test.js b/test/model.indexes.test.js index 290fd59d8fe..366953d50de 100644 --- a/test/model.indexes.test.js +++ b/test/model.indexes.test.js @@ -112,7 +112,7 @@ describe('model', function() { }); const otherSchema = Schema({ name: { type: String, index: true } - }, { excludeIndexes: true }) + }, { excludeIndexes: true }); const User = new Schema({ name: {type: String, index: true},