mongoose-lean-virtuals
Advanced tools
Comparing version 0.7.3 to 0.7.4
@@ -0,1 +1,5 @@ | ||
0.7.4 / 2020-11-20 | ||
================== | ||
* fix: support nested virtuals #43 [rdougan](https://github.com/rdougan) | ||
0.7.3 / 2020-11-12 | ||
@@ -2,0 +6,0 @@ ================== |
16
index.js
@@ -79,3 +79,3 @@ 'use strict'; | ||
applyVirtualsToChildren(this, schema, res, virtualsForChildren); | ||
applyVirtualsToChildren(this, schema, res, virtualsForChildren, parent); | ||
return applyVirtualsToResult(schema, res, toApply, parent); | ||
@@ -102,4 +102,5 @@ } | ||
function applyVirtualsToChildren(doc, schema, res, virtuals) { | ||
function applyVirtualsToChildren(doc, schema, res, virtuals, parent) { | ||
const len = schema.childSchemas.length; | ||
let attachedVirtuals = false; | ||
for (let i = 0; i < len; ++i) { | ||
@@ -128,4 +129,13 @@ const _path = schema.childSchemas[i].model.path; | ||
attachVirtuals.call(doc, _schema, _doc, virtualsForChild, res); | ||
if (virtualsForChild.length > 0) { | ||
attachVirtuals.call(doc, _schema, _doc, virtualsForChild, res); | ||
attachedVirtuals = true; | ||
} | ||
} | ||
if (virtuals && virtuals.length && !attachedVirtuals) { | ||
attachVirtualsToDoc(schema, res, virtuals.map(function(virtual) { | ||
return virtual.join('.'); | ||
}), parent); | ||
} | ||
} | ||
@@ -132,0 +142,0 @@ |
{ | ||
"name": "mongoose-lean-virtuals", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"description": "Attach virtuals to the results of mongoose queries when using `.lean()`", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25258
160