* 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)
| 23 | */ |
| 24 | |
| 25 | function 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 |
nothing calls this directly
no outgoing calls
no test coverage detected