Every line of 'mongoose array of strings' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
26 function MongooseArray(values, path, doc) { 27 var arr = [].concat(values); 28 29 utils.decorate( arr, MongooseArray.mixin ); 30 arr.isMongooseArray = true; 31 32 var _options = { enumerable: false, configurable: true, writable: true }; 33 var keys = Object.keys(MongooseArray.mixin). 34 concat(['isMongooseArray', 'validators', '_path']); 35 for (var i = 0; i < keys.length; ++i) { 36 Object.defineProperty(arr, keys[i], _options); 37 }; 38 39 arr._atomics = {}; 40 arr.validators = []; 41 arr._path = path; 42 43 // Because doc comes from the context of another function, doc === global 44 // can happen if there was a null somewhere up the chain (see #3020) 45 // RB Jun 17, 2015 updated to check for presence of expected paths instead 46 // to make more proof against unusual node environments 47 if (doc && doc instanceof Document) { 48 arr._parent = doc; 49 arr._schema = doc.schema.path(path); 50 } 51 52 return arr; 53 }
26 function MongooseDocumentArray (values, path, doc) { 27 var arr = []; 28 29 // Values always have to be passed to the constructor to initialize, since 30 // otherwise MongooseArray#push will mark the array as modified to the parent. 31 arr.push.apply(arr, values); 32 arr.__proto__ = MongooseDocumentArray.prototype; 33 34 arr._atomics = {}; 35 arr.validators = []; 36 arr._path = path; 37 38 if (doc) { 39 arr._parent = doc; 40 arr._schema = doc.schema.path(path); 41 doc.on('save', arr.notify('save')); 42 doc.on('isNew', arr.notify('isNew')); 43 } 44 45 return arr; 46 };
23 function MongooseDocumentArray (values, path, doc) { 24 var arr = []; 25 arr.push.apply(arr, values); 26 arr.__proto__ = MongooseDocumentArray.prototype; 27 28 arr._atomics = {}; 29 arr.validators = []; 30 arr._path = path; 31 32 if (doc) { 33 arr._parent = doc; 34 arr._schema = doc.schema.path(path); 35 doc.on('save', arr.notify('save')); 36 doc.on('isNew', arr.notify('isNew')); 37 } 38 39 return arr; 40 };