SchemaDocumentArrayOptions.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. 'use strict';
  2. const SchemaTypeOptions = require('./SchemaTypeOptions');
  3. /**
  4. * The options defined on an Document Array schematype.
  5. *
  6. * #### Example:
  7. *
  8. * const schema = new Schema({ users: [{ name: string }] });
  9. * schema.path('users').options; // SchemaDocumentArrayOptions instance
  10. *
  11. * @api public
  12. * @inherits SchemaTypeOptions
  13. * @constructor SchemaDocumentOptions
  14. */
  15. class SchemaDocumentArrayOptions extends SchemaTypeOptions {}
  16. const opts = require('./propertyOptions');
  17. /**
  18. * If `true`, Mongoose will skip building any indexes defined in this array's schema.
  19. * If not set, Mongoose will build all indexes defined in this array's schema.
  20. *
  21. * #### Example:
  22. *
  23. * const childSchema = Schema({ name: { type: String, index: true } });
  24. * // If `excludeIndexes` is `true`, Mongoose will skip building an index
  25. * // on `arr.name`. Otherwise, Mongoose will build an index on `arr.name`.
  26. * const parentSchema = Schema({
  27. * arr: { type: [childSchema], excludeIndexes: true }
  28. * });
  29. *
  30. * @api public
  31. * @property excludeIndexes
  32. * @memberOf SchemaDocumentArrayOptions
  33. * @type Array
  34. * @instance
  35. */
  36. Object.defineProperty(SchemaDocumentArrayOptions.prototype, 'excludeIndexes', opts);
  37. /**
  38. * If set, overwrites the child schema's `_id` option.
  39. *
  40. * #### Example:
  41. *
  42. * const childSchema = Schema({ name: String });
  43. * const parentSchema = Schema({
  44. * child: { type: childSchema, _id: false }
  45. * });
  46. * parentSchema.path('child').schema.options._id; // false
  47. *
  48. * @api public
  49. * @property _id
  50. * @memberOf SchemaDocumentArrayOptions
  51. * @type Array
  52. * @instance
  53. */
  54. Object.defineProperty(SchemaDocumentArrayOptions.prototype, '_id', opts);
  55. /*!
  56. * ignore
  57. */
  58. module.exports = SchemaDocumentArrayOptions;