MCPcopy Create free account
hub / github.com/Automattic/mongoose / SubdocumentPath

Function SubdocumentPath

lib/schema/SubdocumentPath.js:38–58  ·  view source on GitHub ↗

* Single nested subdocument SchemaType constructor. * * @param {Schema} schema * @param {String} path * @param {Object} options * @inherits SchemaType * @api public

(schema, path, options)

Source from the content-addressed store, hash-verified

36 */
37
38function SubdocumentPath(schema, path, options) {
39 if (schema.options.timeseries) {
40 throw new InvalidSchemaOptionError(path, 'timeseries');
41 }
42 const schemaTypeIdOption = SubdocumentPath.defaultOptions &&
43 SubdocumentPath.defaultOptions._id;
44 if (schemaTypeIdOption != null) {
45 options = options || {};
46 options._id = schemaTypeIdOption;
47 }
48
49 schema = handleIdOption(schema, options);
50
51 this.caster = _createConstructor(schema, null, options);
52 this.caster.path = path;
53 this.caster.prototype.$basePath = path;
54 this.schema = schema;
55 this.$isSingleNested = true;
56 this.base = schema.base;
57 SchemaType.call(this, path, options, 'Embedded');
58}
59
60/*!
61 * ignore

Callers

nothing calls this directly

Calls 1

_createConstructorFunction · 0.70

Tested by

no test coverage detected