SingleNestedPath
SingleNestedPath()
Parameters
- schema «Schema»
- key «String»
- options «Object»
Inherits:
- «SchemaType»
Single nested subdocument SchemaType constructor.
SingleNestedPath.prototype.discriminator()
Parameters
- name «String»
schema «Schema» fields to add to the schema for instances of this sub-class
[value] «String» the string stored in the
discriminatorKey
property. If not specified, Mongoose uses thename
parameter.
Returns:
- «Function» the constructor Mongoose will use for creating instances of this discriminator model
Adds a discriminator to this single nested subdocument.
Example:
const shapeSchema = Schema({ name: String }, { discriminatorKey: 'kind' });
const schema = Schema({ shape: shapeSchema });
const singleNestedPath = parentSchema.path('shape');
singleNestedPath.discriminator('Circle', Schema({ radius: Number }));
function Object() { [native code] }.
Parameters
- option «String»
- The option you’d like to set the value for
- value «*»
- value for option
Returns:
- «undefined»
Type:
- «property»
Sets a default option for all SingleNestedPath instances.
Example:
// Make all numbers have option `min` equal to 0.
mongoose.Schema.Embedded.set('required', true);
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .