Refactoring day1
This commit is contained in:
22
node_modules/mongoose/lib/schema/SingleNestedPath.js
generated
vendored
22
node_modules/mongoose/lib/schema/SingleNestedPath.js
generated
vendored
@@ -175,7 +175,7 @@ SingleNestedPath.prototype.cast = function(val, doc, init, priorVal) {
|
||||
subdoc.init(val);
|
||||
} else {
|
||||
if (Object.keys(val).length === 0) {
|
||||
return new Constructor({}, selected, doc, undefined, { priorDoc: priorVal });
|
||||
return new Constructor({}, selected, doc);
|
||||
}
|
||||
|
||||
return new Constructor(val, selected, doc, undefined, { priorDoc: priorVal });
|
||||
@@ -300,26 +300,6 @@ SingleNestedPath.prototype.discriminator = function(name, schema, value) {
|
||||
return this.caster.discriminators[name];
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets a default option for all SingleNestedPath instances.
|
||||
*
|
||||
* ####Example:
|
||||
*
|
||||
* // Make all numbers have option `min` equal to 0.
|
||||
* mongoose.Schema.Embedded.set('required', true);
|
||||
*
|
||||
* @param {String} option - The option you'd like to set the value for
|
||||
* @param {*} value - value for option
|
||||
* @return {undefined}
|
||||
* @function set
|
||||
* @static
|
||||
* @api public
|
||||
*/
|
||||
|
||||
SingleNestedPath.defaultOptions = {};
|
||||
|
||||
SingleNestedPath.set = SchemaType.set;
|
||||
|
||||
/*!
|
||||
* ignore
|
||||
*/
|
||||
|
||||
2
node_modules/mongoose/lib/schema/array.js
generated
vendored
2
node_modules/mongoose/lib/schema/array.js
generated
vendored
@@ -280,7 +280,7 @@ SchemaArray.prototype._applySetters = function(value, scope, init, priorVal) {
|
||||
// No need to wrap empty arrays
|
||||
if (value != null && value.length > 0) {
|
||||
const valueDepth = arrayDepth(value);
|
||||
if (valueDepth.min === valueDepth.max && valueDepth.max < depth && valueDepth.containsNonArrayItem) {
|
||||
if (valueDepth.min === valueDepth.max && valueDepth.max < depth) {
|
||||
for (let i = valueDepth.max; i < depth; ++i) {
|
||||
value = [value];
|
||||
}
|
||||
|
||||
24
node_modules/mongoose/lib/schema/boolean.js
generated
vendored
24
node_modules/mongoose/lib/schema/boolean.js
generated
vendored
@@ -224,30 +224,6 @@ SchemaBoolean.prototype.castForQuery = function($conditional, val) {
|
||||
return this._castForQuery($conditional);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SchemaBoolean.prototype._castNullish = function _castNullish(v) {
|
||||
if (typeof v === 'undefined' && this.$$context != null && this.$$context._mongooseOptions.omitUndefined) {
|
||||
return v;
|
||||
}
|
||||
const castBoolean = typeof this.constructor.cast === 'function' ?
|
||||
this.constructor.cast() :
|
||||
SchemaBoolean.cast();
|
||||
if (castBoolean == null) {
|
||||
return v;
|
||||
}
|
||||
if (castBoolean.convertToFalse instanceof Set && castBoolean.convertToFalse.has(v)) {
|
||||
return false;
|
||||
}
|
||||
if (castBoolean.convertToTrue instanceof Set && castBoolean.convertToTrue.has(v)) {
|
||||
return true;
|
||||
}
|
||||
return v;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
25
node_modules/mongoose/lib/schema/documentarray.js
generated
vendored
25
node_modules/mongoose/lib/schema/documentarray.js
generated
vendored
@@ -361,11 +361,6 @@ DocumentArrayPath.prototype.cast = function(value, doc, init, prev, options) {
|
||||
// lazy load
|
||||
MongooseDocumentArray || (MongooseDocumentArray = require('../types/documentarray'));
|
||||
|
||||
// Skip casting if `value` is the same as the previous value, no need to cast. See gh-9266
|
||||
if (value != null && value[arrayPathSymbol] != null && value === prev) {
|
||||
return value;
|
||||
}
|
||||
|
||||
let selected;
|
||||
let subdoc;
|
||||
const _opts = { transform: false, virtuals: false };
|
||||
@@ -518,26 +513,6 @@ function scopePaths(array, fields, init) {
|
||||
return hasKeys && selected || undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a default option for all DocumentArray instances.
|
||||
*
|
||||
* ####Example:
|
||||
*
|
||||
* // Make all numbers have option `min` equal to 0.
|
||||
* mongoose.Schema.DocumentArray.set('_id', false);
|
||||
*
|
||||
* @param {String} option - The option you'd like to set the value for
|
||||
* @param {*} value - value for option
|
||||
* @return {undefined}
|
||||
* @function set
|
||||
* @static
|
||||
* @api public
|
||||
*/
|
||||
|
||||
DocumentArrayPath.defaultOptions = {};
|
||||
|
||||
DocumentArrayPath.set = SchemaType.set;
|
||||
|
||||
/*!
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
4
node_modules/mongoose/lib/schema/string.js
generated
vendored
4
node_modules/mongoose/lib/schema/string.js
generated
vendored
@@ -516,10 +516,6 @@ SchemaString.prototype.match = function match(regExp, message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// In case RegExp happens to have `/g` flag set, we need to reset the
|
||||
// `lastIndex`, otherwise `match` will intermittently fail.
|
||||
regExp.lastIndex = 0;
|
||||
|
||||
const ret = ((v != null && v !== '')
|
||||
? regExp.test(v)
|
||||
: true);
|
||||
|
||||
Reference in New Issue
Block a user