SchemaSubdocumentOptions.js 1023 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. const SchemaTypeOptions = require('./SchemaTypeOptions');
  3. /**
  4. * The options defined on a single nested schematype.
  5. *
  6. * #### Example:
  7. *
  8. * const schema = Schema({ child: Schema({ name: String }) });
  9. * schema.path('child').options; // SchemaSubdocumentOptions instance
  10. *
  11. * @api public
  12. * @inherits SchemaTypeOptions
  13. * @constructor SchemaSubdocumentOptions
  14. */
  15. class SchemaSubdocumentOptions extends SchemaTypeOptions {}
  16. const opts = require('./propertyOptions');
  17. /**
  18. * If set, overwrites the child schema's `_id` option.
  19. *
  20. * #### Example:
  21. *
  22. * const childSchema = Schema({ name: String });
  23. * const parentSchema = Schema({
  24. * child: { type: childSchema, _id: false }
  25. * });
  26. * parentSchema.path('child').schema.options._id; // false
  27. *
  28. * @api public
  29. * @property of
  30. * @memberOf SchemaSubdocumentOptions
  31. * @type Function|string
  32. * @instance
  33. */
  34. Object.defineProperty(SchemaSubdocumentOptions.prototype, '_id', opts);
  35. module.exports = SchemaSubdocumentOptions;