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

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('child');
singleNestedPath.discriminator('Circle', Schema({ radius: Number }));