SchemaNumberOptions.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. 'use strict';
  2. const SchemaTypeOptions = require('./SchemaTypeOptions');
  3. /**
  4. * The options defined on a Number schematype.
  5. *
  6. * ####Example:
  7. *
  8. * const schema = new Schema({ count: Number });
  9. * schema.path('count').options; // SchemaNumberOptions instance
  10. *
  11. * @api public
  12. * @inherits SchemaTypeOptions
  13. * @constructor SchemaNumberOptions
  14. */
  15. class SchemaNumberOptions extends SchemaTypeOptions {}
  16. const opts = require('./propertyOptions');
  17. /**
  18. * If set, Mongoose adds a validator that checks that this path is at least the
  19. * given `min`.
  20. *
  21. * @api public
  22. * @property min
  23. * @memberOf SchemaNumberOptions
  24. * @type Number
  25. * @instance
  26. */
  27. Object.defineProperty(SchemaNumberOptions.prototype, 'min', opts);
  28. /**
  29. * If set, Mongoose adds a validator that checks that this path is less than the
  30. * given `max`.
  31. *
  32. * @api public
  33. * @property max
  34. * @memberOf SchemaNumberOptions
  35. * @type Number
  36. * @instance
  37. */
  38. Object.defineProperty(SchemaNumberOptions.prototype, 'max', opts);
  39. /**
  40. * If set, Mongoose adds a validator that checks that this path is strictly
  41. * equal to one of the given values.
  42. *
  43. * ####Example:
  44. * const schema = new Schema({
  45. * favoritePrime: {
  46. * type: Number,
  47. * enum: [3, 5, 7]
  48. * }
  49. * });
  50. * schema.path('favoritePrime').options.enum; // [3, 5, 7]
  51. *
  52. * @api public
  53. * @property enum
  54. * @memberOf SchemaNumberOptions
  55. * @type Array
  56. * @instance
  57. */
  58. Object.defineProperty(SchemaNumberOptions.prototype, 'enum', opts);
  59. /*!
  60. * ignore
  61. */
  62. module.exports = SchemaNumberOptions;