SchemaDateOptions.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. 'use strict';
  2. const SchemaTypeOptions = require('./SchemaTypeOptions');
  3. /**
  4. * The options defined on a Date schematype.
  5. *
  6. * #### Example:
  7. *
  8. * const schema = new Schema({ startedAt: Date });
  9. * schema.path('startedAt').options; // SchemaDateOptions instance
  10. *
  11. * @api public
  12. * @inherits SchemaTypeOptions
  13. * @constructor SchemaDateOptions
  14. */
  15. class SchemaDateOptions extends SchemaTypeOptions {}
  16. const opts = require('./propertyOptions');
  17. /**
  18. * If set, Mongoose adds a validator that checks that this path is after the
  19. * given `min`.
  20. *
  21. * @api public
  22. * @property min
  23. * @memberOf SchemaDateOptions
  24. * @type Date
  25. * @instance
  26. */
  27. Object.defineProperty(SchemaDateOptions.prototype, 'min', opts);
  28. /**
  29. * If set, Mongoose adds a validator that checks that this path is before the
  30. * given `max`.
  31. *
  32. * @api public
  33. * @property max
  34. * @memberOf SchemaDateOptions
  35. * @type Date
  36. * @instance
  37. */
  38. Object.defineProperty(SchemaDateOptions.prototype, 'max', opts);
  39. /**
  40. * If set, Mongoose creates a TTL index on this path.
  41. *
  42. * mongo TTL index `expireAfterSeconds` value will take 'expires' value expressed in seconds.
  43. *
  44. * #### Example:
  45. *
  46. * const schema = new Schema({ "expireAt": { type: Date, expires: 11 } });
  47. * // if 'expireAt' is set, then document expires at expireAt + 11 seconds
  48. *
  49. * @api public
  50. * @property expires
  51. * @memberOf SchemaDateOptions
  52. * @type Date
  53. * @instance
  54. */
  55. Object.defineProperty(SchemaDateOptions.prototype, 'expires', opts);
  56. /*!
  57. * ignore
  58. */
  59. module.exports = SchemaDateOptions;