* SubdocsArray SchemaType constructor * * @param {String} key * @param {Schema} schema * @param {Object} options * @inherits SchemaArray * @api public
(key, schema, options)
| 26 | */ |
| 27 | |
| 28 | function DocumentArray(key, schema, options) { |
| 29 | var EmbeddedDocument = _createConstructor(schema, options); |
| 30 | |
| 31 | ArrayType.call(this, key, EmbeddedDocument, options); |
| 32 | |
| 33 | this.schema = schema; |
| 34 | this.$isMongooseDocumentArray = true; |
| 35 | var fn = this.defaultValue; |
| 36 | |
| 37 | if (!('defaultValue' in this) || fn !== void 0) { |
| 38 | this.default(function() { |
| 39 | var arr = fn.call(this); |
| 40 | if (!Array.isArray(arr)) { |
| 41 | arr = [arr]; |
| 42 | } |
| 43 | // Leave it up to `cast()` to convert this to a documentarray |
| 44 | return arr; |
| 45 | }); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * This schema type's name, to defend against minifiers that mangle |
nothing calls this directly
no test coverage detected