You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
832 B

  1. /*!
  2. * Module dependencies.
  3. */
  4. var SchemaType = require('../schematype')
  5. , CastError = SchemaType.CastError
  6. , errorMessages = require('../error').messages
  7. , utils = require('../utils')
  8. , Document
  9. /**
  10. * EmbeddedDocument SchemaType constructor.
  11. *
  12. * @param {String} key
  13. * @param {Object} options
  14. * @inherits SchemaType
  15. * @api private
  16. */
  17. function SchemaEmbedded (key, options, EmbeddedDoc, parentArray) {
  18. SchemaType.call(this, key, options, 'EmbeddedDocument');
  19. this.EmbeddedDoc = EmbeddedDoc;
  20. this.parentArray = parentArray;
  21. };
  22. /*!
  23. * Inherits from SchemaType.
  24. */
  25. SchemaEmbedded.prototype.__proto__ = SchemaType.prototype;
  26. SchemaEmbedded.prototype.cast = function (value, doc, init) {
  27. return new this.EmbeddedDoc(value, this.parentArray);
  28. }
  29. /*!
  30. * Module exports.
  31. */
  32. module.exports = SchemaEmbedded;