Every line of 'mongoose populate multiple' 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.
173 async populate(modelName, data, populates) { 174 try { 175 const model = this.Models[modelName]; 176 return await model.populate(data, populates); 177 } catch (e) { 178 return Promise.reject(e); 179 } 180 }
103 var populate = function populate(collection) { 104 105 if (_this.populate_keys && _this.populate_keys.length > 0) _this.populate_keys.forEach(function (key) { 106 var ref = collection[key]; 107 if (ref) { 108 var db = new LocalDB(ref.__className, 'Array'); 109 var temp = db.findOne({ '_id': ref.objectId }); 110 collection[key] = temp; 111 } 112 }); 113 return collection; 114 };
52 populate(populate) { 53 const queryJoins = buildQueryJoins(this.model, { whitelistedPopulate: populate }); 54 const existingPipelines = this.query.pipeline(); 55 // Remove redundant joins 56 const differenceJoins = _.differenceWith(queryJoins, existingPipelines, _.isEqual); 57 this.query = this.query.append(differenceJoins); 58 return this; 59 }
66 get populates() { 67 return this.query.populates; 68 }
162 _populate(data) { 163 // Links are taken apart and separated out from the data 164 const rawData = Object.assign({}, data); 165 const linkData = rawData.links; 166 delete rawData.links; 167 168 super._populate(rawData); 169 this._links = processLinks(linkData); 170 return this; 171 }
94 populate(expr) { 95 const stack = this._schema._parsePopulate(expr); 96 return this._model._populate(this, stack); 97 }
23 function MongooseDocumentArray(values, path, doc) { 24 var arr = [].concat(values); 25 arr._path = path; 26 27 var props = { 28 isMongooseArray: true, 29 isMongooseDocumentArray: true, 30 validators: [], 31 _atomics: {}, 32 _schema: void 0, 33 _handlers: void 0 34 }; 35 36 // Values always have to be passed to the constructor to initialize, since 37 // otherwise MongooseArray#push will mark the array as modified to the parent. 38 var keysMA = Object.keys(MongooseArray.mixin); 39 var numKeys = keysMA.length; 40 for (var j = 0; j < numKeys; ++j) { 41 arr[keysMA[j]] = MongooseArray.mixin[keysMA[j]]; 42 } 43 44 var keysMDA = Object.keys(MongooseDocumentArray.mixin); 45 numKeys = keysMDA.length; 46 for (var i = 0; i < numKeys; ++i) { 47 arr[keysMDA[i]] = MongooseDocumentArray.mixin[keysMDA[i]]; 48 } 49 50 var keysP = Object.keys(props); 51 numKeys = keysP.length; 52 for (var k = 0; k < numKeys; ++k) { 53 arr[keysP[k]] = props[keysP[k]]; 54 } 55 56 // Because doc comes from the context of another function, doc === global 57 // can happen if there was a null somewhere up the chain (see #3020 && #3034) 58 // RB Jun 17, 2015 updated to check for presence of expected paths instead 59 // to make more proof against unusual node environments 60 if (doc && doc instanceof Document) { 61 arr._parent = doc; 62 arr._schema = doc.schema.path(path); 63 arr._handlers = { 64 isNew: arr.notify('isNew'), 65 save: arr.notify('save') 66 }; 67 68 doc.on('save', arr._handlers.save); 69 doc.on('isNew', arr._handlers.isNew); 70 } 71 72 return arr; 73 }