MCPcopy
hub / github.com/Automattic/mongoose / _completeOneLean

Function _completeOneLean

lib/query.js:4038–4068  ·  view source on GitHub ↗
(schema, doc, path, res, opts, callback)

Source from the content-addressed store, hash-verified

4036 */
4037
4038function _completeOneLean(schema, doc, path, res, opts, callback) {
4039 if (opts.lean && typeof opts.lean.transform === 'function') {
4040 opts.lean.transform(doc);
4041
4042 for (let i = 0; i < schema.childSchemas.length; i++) {
4043 const childPath = path ? path + '.' + schema.childSchemas[i].model.path : schema.childSchemas[i].model.path;
4044 const _schema = schema.childSchemas[i].schema;
4045 const obj = mpath.get(childPath, doc);
4046 if (obj == null) {
4047 continue;
4048 }
4049 if (Array.isArray(obj)) {
4050 for (let i = 0; i < obj.length; i++) {
4051 opts.lean.transform(obj[i]);
4052 }
4053 } else {
4054 opts.lean.transform(obj);
4055 }
4056 _completeOneLean(_schema, obj, childPath, res, opts);
4057 }
4058 if (callback) {
4059 return callback(null, doc);
4060 } else {
4061 return;
4062 }
4063 }
4064 if (opts.includeResultMetadata) {
4065 return callback(null, res);
4066 }
4067 return callback(null, doc);
4068}
4069
4070/*!
4071 * ignore

Callers 1

query.jsFile · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…