mirror of
https://github.com/JonasunderscoreJones/jonas_jones-api.git
synced 2025-10-25 01:59:18 +02:00
some progress
This commit is contained in:
parent
aea93a5527
commit
e3c15bd288
1388 changed files with 306946 additions and 68323 deletions
36
node_modules/mongoose/lib/helpers/query/completeMany.js
generated
vendored
Normal file
36
node_modules/mongoose/lib/helpers/query/completeMany.js
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
const helpers = require('../../queryhelpers');
|
||||
|
||||
module.exports = completeMany;
|
||||
|
||||
/**
|
||||
* Given a model and an array of docs, hydrates all the docs to be instances
|
||||
* of the model. Used to initialize docs returned from the db from `find()`
|
||||
*
|
||||
* @param {Model} model
|
||||
* @param {Array} docs
|
||||
* @param {Object} fields the projection used, including `select` from schemas
|
||||
* @param {Object} userProvidedFields the user-specified projection
|
||||
* @param {Object} [opts]
|
||||
* @param {Array} [opts.populated]
|
||||
* @param {ClientSession} [opts.session]
|
||||
* @param {Function} callback
|
||||
* @api private
|
||||
*/
|
||||
|
||||
async function completeMany(model, docs, fields, userProvidedFields, opts) {
|
||||
return Promise.all(docs.map(doc => new Promise((resolve, reject) => {
|
||||
const rawDoc = doc;
|
||||
doc = helpers.createModel(model, doc, fields, userProvidedFields);
|
||||
if (opts.session != null) {
|
||||
doc.$session(opts.session);
|
||||
}
|
||||
doc.$init(rawDoc, opts, (err) => {
|
||||
if (err != null) {
|
||||
return reject(err);
|
||||
}
|
||||
resolve(doc);
|
||||
});
|
||||
})));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue