-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use options constructor for array, buffer, date schematypes…
… re: #8012
- Loading branch information
Showing
7 changed files
with
127 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters