From ab3158acdaaf87ab0fff322d0a67047af6f9136d Mon Sep 17 00:00:00 2001 From: yamaha252 Date: Thu, 28 Nov 2024 15:43:57 +0500 Subject: [PATCH] fix: virtual population provides hydration options --- lib/schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/schema.js b/lib/schema.js index a9d23fd619..3eabf9f847 100644 --- a/lib/schema.js +++ b/lib/schema.js @@ -2348,12 +2348,12 @@ Schema.prototype.virtual = function(name, options) { const populatedVal = this.$$populatedVirtuals[name]; if (!Array.isArray(populatedVal) && !populatedVal.$__ && modelNames?.length === 1) { const PopulateModel = this.db.model(modelNames[0]); - this.$$populatedVirtuals[name] = PopulateModel.hydrate(populatedVal); + this.$$populatedVirtuals[name] = PopulateModel.hydrate(populatedVal, undefined, opts); } else if (Array.isArray(populatedVal) && modelNames?.length === 1) { const PopulateModel = this.db.model(modelNames[0]); for (let i = 0; i < populatedVal.length; ++i) { if (!populatedVal[i].$__) { - populatedVal[i] = PopulateModel.hydrate(populatedVal[i]); + populatedVal[i] = PopulateModel.hydrate(populatedVal[i], undefined, opts); } } }