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

Function SchemaDocumentArrayElement

lib/schema/documentArrayElement.js:27–39  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

25 */
26
27function 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected