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