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

Function ArraySubdocument

lib/types/ArraySubdocument.js:25–45  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected