* DocumentArrayElement SchemaType constructor. Mongoose calls this internally when you define a new document array in your schema. * * #### Example: * const schema = new Schema({ users: [{ name: String }] }); * schema.path('users.$'); // SchemaDocumentArrayElement with schema `new Schema
(path, schema, options, parentSchema)
| 25 | */ |
| 26 | |
| 27 | function SchemaDocumentArrayElement(path, schema, options, parentSchema) { |
| 28 | this.$parentSchemaType = options?.$parentSchemaType; |
| 29 | if (!this.$parentSchemaType) { |
| 30 | throw new MongooseError('Cannot create DocumentArrayElement schematype without a parent'); |
| 31 | } |
| 32 | delete options.$parentSchemaType; |
| 33 | |
| 34 | SchemaType.call(this, path, options, 'DocumentArrayElement', parentSchema); |
| 35 | |
| 36 | this.$isMongooseDocumentArrayElement = true; |
| 37 | this.Constructor = options?.Constructor; |
| 38 | this.schema = schema; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * This schema type's name, to defend against minifiers that mangle |
nothing calls this directly
no outgoing calls
no test coverage detected