diff --git a/lib/options/SchemaArrayOptions.js b/lib/options/SchemaArrayOptions.js new file mode 100644 index 00000000000..330ac2db5e9 --- /dev/null +++ b/lib/options/SchemaArrayOptions.js @@ -0,0 +1,31 @@ +'use strict'; + +const SchemaTypeOptions = require('./SchemaTypeOptions'); + +class SchemaArrayOptions extends SchemaTypeOptions {} + +const opts = { + enumerable: true, + configurable: true, + writable: true, + value: null +}; + +/** + * If this is an array of strings, an array of allowed values for this path. + * Throws an error if this array isn't an array of strings. + * + * @api public + * @property enum + * @memberOf SchemaArrayOptions + * @type Array + * @instance + */ + +Object.defineProperty(SchemaArrayOptions.prototype, 'enum', opts); + +/*! + * ignore + */ + +module.exports = SchemaArrayOptions; \ No newline at end of file diff --git a/lib/options/SchemaBufferOptions.js b/lib/options/SchemaBufferOptions.js new file mode 100644 index 00000000000..4ee8957ba2a --- /dev/null +++ b/lib/options/SchemaBufferOptions.js @@ -0,0 +1,30 @@ +'use strict'; + +const SchemaTypeOptions = require('./SchemaTypeOptions'); + +class SchemaBufferOptions extends SchemaTypeOptions {} + +const opts = { + enumerable: true, + configurable: true, + writable: true, + value: null +}; + +/** + * Set the default subtype for this buffer. + * + * @api public + * @property subtype + * @memberOf SchemaBufferOptions + * @type Number + * @instance + */ + +Object.defineProperty(SchemaBufferOptions.prototype, 'subtype', opts); + +/*! + * ignore + */ + +module.exports = SchemaBufferOptions; \ No newline at end of file diff --git a/lib/options/SchemaDateOptions.js b/lib/options/SchemaDateOptions.js new file mode 100644 index 00000000000..5334e5f66c3 --- /dev/null +++ b/lib/options/SchemaDateOptions.js @@ -0,0 +1,56 @@ +'use strict'; + +const SchemaTypeOptions = require('./SchemaTypeOptions'); + +class SchemaDateOptions extends SchemaTypeOptions {} + +const opts = { + enumerable: true, + configurable: true, + writable: true, + value: null +}; + +/** + * If set, Mongoose adds a validator that checks that this path is after the + * given `min`. + * + * @api public + * @property min + * @memberOf SchemaDateOptions + * @type Date + * @instance + */ + +Object.defineProperty(SchemaDateOptions.prototype, 'min', opts); + +/** + * If set, Mongoose adds a validator that checks that this path is before the + * given `max`. + * + * @api public + * @property max + * @memberOf SchemaDateOptions + * @type Date + * @instance + */ + +Object.defineProperty(SchemaDateOptions.prototype, 'max', opts); + +/** + * If set, Mongoose creates a TTL index on this path. + * + * @api public + * @property expires + * @memberOf SchemaDateOptions + * @type Date + * @instance + */ + +Object.defineProperty(SchemaDateOptions.prototype, 'expires', opts); + +/*! + * ignore + */ + +module.exports = SchemaDateOptions; \ No newline at end of file diff --git a/lib/options/SchemaNumberOptions.js b/lib/options/SchemaNumberOptions.js index 2186a83740b..6bb57e3cd98 100644 --- a/lib/options/SchemaNumberOptions.js +++ b/lib/options/SchemaNumberOptions.js @@ -25,7 +25,7 @@ const opts = { Object.defineProperty(SchemaNumberOptions.prototype, 'min', opts); /** - * If set, Mongoose adds a validator that checks that this path is at least the + * If set, Mongoose adds a validator that checks that this path is less than the * given `max`. * * @api public diff --git a/lib/schema/array.js b/lib/schema/array.js index 3ffc7cae585..718961df23d 100644 --- a/lib/schema/array.js +++ b/lib/schema/array.js @@ -7,6 +7,7 @@ const $exists = require('./operators/exists'); const $type = require('./operators/type'); const MongooseError = require('../error/mongooseError'); +const SchemaArrayOptions = require('../options/SchemaArrayOptions'); const SchemaType = require('../schematype'); const CastError = SchemaType.CastError; const Mixed = require('./mixed'); @@ -134,6 +135,7 @@ SchemaArray.options = { castNonArrays: true }; */ SchemaArray.prototype = Object.create(SchemaType.prototype); SchemaArray.prototype.constructor = SchemaArray; +SchemaArray.prototype.OptionsConstructor = SchemaArrayOptions; /*! * ignore diff --git a/lib/schema/buffer.js b/lib/schema/buffer.js index 6b6868ef46e..69ccdaa8af5 100644 --- a/lib/schema/buffer.js +++ b/lib/schema/buffer.js @@ -4,14 +4,14 @@ 'use strict'; +const MongooseBuffer = require('../types/buffer'); +const SchemaBufferOptions = require('../options/SchemaBufferOptions'); +const SchemaType = require('../schematype'); const handleBitwiseOperator = require('./operators/bitwise'); const utils = require('../utils'); const populateModelSymbol = require('../helpers/symbols').populateModelSymbol; -const MongooseBuffer = require('../types/buffer'); -const SchemaType = require('../schematype'); - const Binary = MongooseBuffer.Binary; const CastError = SchemaType.CastError; let Document; @@ -42,6 +42,7 @@ SchemaBuffer.schemaName = 'Buffer'; */ SchemaBuffer.prototype = Object.create(SchemaType.prototype); SchemaBuffer.prototype.constructor = SchemaBuffer; +SchemaBuffer.prototype.OptionsConstructor = SchemaBufferOptions; /*! * ignore diff --git a/lib/schema/date.js b/lib/schema/date.js index 576039b4fb8..6a0e9aae46b 100644 --- a/lib/schema/date.js +++ b/lib/schema/date.js @@ -5,11 +5,11 @@ 'use strict'; const MongooseError = require('../error/index'); +const SchemaDateOptions = require('../options/SchemaDateOptions'); +const SchemaType = require('../schematype'); const castDate = require('../cast/date'); const utils = require('../utils'); -const SchemaType = require('../schematype'); - const CastError = SchemaType.CastError; /** @@ -38,6 +38,7 @@ SchemaDate.schemaName = 'Date'; */ SchemaDate.prototype = Object.create(SchemaType.prototype); SchemaDate.prototype.constructor = SchemaDate; +SchemaDate.prototype.OptionsConstructor = SchemaDateOptions; /*! * ignore