SchemaMapOptions.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. const SchemaTypeOptions = require('./SchemaTypeOptions');
  3. /**
  4. * The options defined on a Map schematype.
  5. *
  6. * ####Example:
  7. *
  8. * const schema = new Schema({ socialMediaHandles: { type: Map, of: String } });
  9. * schema.path('socialMediaHandles').options; // SchemaMapOptions instance
  10. *
  11. * @api public
  12. * @inherits SchemaTypeOptions
  13. * @constructor SchemaMapOptions
  14. */
  15. class SchemaMapOptions extends SchemaTypeOptions {}
  16. const opts = require('./propertyOptions');
  17. /**
  18. * If set, specifies the type of this map's values. Mongoose will cast
  19. * this map's values to the given type.
  20. *
  21. * If not set, Mongoose will not cast the map's values.
  22. *
  23. * ####Example:
  24. *
  25. * // Mongoose will cast `socialMediaHandles` values to strings
  26. * const schema = new Schema({ socialMediaHandles: { type: Map, of: String } });
  27. * schema.path('socialMediaHandles').options.of; // String
  28. *
  29. * @api public
  30. * @property of
  31. * @memberOf SchemaMapOptions
  32. * @type Function|string
  33. * @instance
  34. */
  35. Object.defineProperty(SchemaMapOptions.prototype, 'of', opts);
  36. module.exports = SchemaMapOptions;