Cleanup
This commit is contained in:
30
node_modules/mongoose/lib/schema/SingleNestedPath.js
generated
vendored
30
node_modules/mongoose/lib/schema/SingleNestedPath.js
generated
vendored
@@ -62,7 +62,7 @@ function _createConstructor(schema, baseClass) {
|
||||
const _embedded = function SingleNested(value, path, parent) {
|
||||
const _this = this;
|
||||
|
||||
this.$parent = parent;
|
||||
this.$__parent = parent;
|
||||
Subdocument.apply(this, arguments);
|
||||
|
||||
this.$session(this.ownerDocument().$session());
|
||||
@@ -147,7 +147,7 @@ SingleNestedPath.prototype.$conditionalHandlers.$exists = $exists;
|
||||
* @api private
|
||||
*/
|
||||
|
||||
SingleNestedPath.prototype.cast = function(val, doc, init, priorVal) {
|
||||
SingleNestedPath.prototype.cast = function(val, doc, init, priorVal, options) {
|
||||
if (val && val.$isSingleNested && val.parent === doc) {
|
||||
return val;
|
||||
}
|
||||
@@ -169,16 +169,16 @@ SingleNestedPath.prototype.cast = function(val, doc, init, priorVal) {
|
||||
}
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
options = Object.assign({}, options, { priorDoc: priorVal });
|
||||
if (init) {
|
||||
subdoc = new Constructor(void 0, selected, doc);
|
||||
subdoc.init(val);
|
||||
} else {
|
||||
if (Object.keys(val).length === 0) {
|
||||
return new Constructor({}, selected, doc);
|
||||
return new Constructor({}, selected, doc, undefined, options);
|
||||
}
|
||||
|
||||
return new Constructor(val, selected, doc, undefined, { priorDoc: priorVal });
|
||||
return new Constructor(val, selected, doc, undefined, options);
|
||||
}
|
||||
|
||||
return subdoc;
|
||||
@@ -300,6 +300,26 @@ 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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user