arnaucube
arnaucube/thoughtsPublic Self-hosted repository
thoughts/node_modules/mongoose/lib/schema/embedded.js
node_modules/mongoose/lib/schema/embedded.jsRaw
 1
 2/*!
 3 * Module dependencies.
 4 */
 5
 6var SchemaType = require('../schematype')
 7  , CastError = SchemaType.CastError
 8  , errorMessages = require('../error').messages
 9  , utils = require('../utils')
10  , Document
11
12/**
13 * EmbeddedDocument SchemaType constructor.
14 *
15 * @param {String} key
16 * @param {Object} options
17 * @inherits SchemaType
18 * @api private
19 */
20
21function SchemaEmbedded (key, options, EmbeddedDoc, parentArray) {
22  SchemaType.call(this, key, options, 'EmbeddedDocument');
23  this.EmbeddedDoc = EmbeddedDoc;
24  this.parentArray = parentArray;
25};
26
27/*!
28 * Inherits from SchemaType.
29 */
30
31SchemaEmbedded.prototype.__proto__ = SchemaType.prototype;
32
33SchemaEmbedded.prototype.cast = function (value, doc, init) {
34  return new this.EmbeddedDoc(value, this.parentArray);
35}
36
37/*!
38 * Module exports.
39 */
40
41module.exports = SchemaEmbedded;