Schema.prototype.pathType()

Parameters
  • path «String»
Returns:
  • «String»

Returns the pathType of path for this schema.

Given a path, returns whether it is a real, virtual, nested, or ad-hoc/undefined path.

Example:

  1. const s = new Schema({ name: String, nested: { foo: String } });
  2. s.virtual('foo').get(() => 42);
  3. s.pathType('name'); // "real"
  4. s.pathType('nested'); // "nested"
  5. s.pathType('foo'); // "virtual"
  6. s.pathType('fail'); // "adhocOrUndefined"