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

Function ArraySubdocument

lib/types/arraySubdocument.js:26–47  ·  view source on GitHub ↗

* A constructor. * * @param {object} obj js object returned from the db * @param {MongooseDocumentArray} parentArr the parent array of this document * @param {boolean} skipId * @param {object} fields * @param {number} index * @inherits Document * @api private

(obj, parentArr, skipId, fields, index)

Source from the content-addressed store, hash-verified

24 */
25
26function ArraySubdocument(obj, parentArr, skipId, fields, index) {
27 let parent;
28 if (utils.isMongooseDocumentArray(parentArr)) {
29 this.__parentArray = parentArr;
30 parent = parentArr[arrayParentSymbol];
31 } else {
32 this.__parentArray = undefined;
33 }
34 this[documentArrayParent] = parent;
35 this.$setIndex(index);
36 this.$__parent = parent;
37
38 const options = { isNew: true };
39 if (parent != null && 'defaults' in parent.$__) {
40 options.defaults = parent.$__.defaults;
41 }
42 if (typeof skipId === 'object' && skipId != null) {
43 Object.assign(options, skipId);
44 }
45
46 Subdocument.call(this, obj, fields, null, options);
47}
48
49/*!
50 * Inherit from Subdocument

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected