Skip to content

Commit

Permalink
fix: virtual population provides hydration options
Browse files Browse the repository at this point in the history
  • Loading branch information
yamaha252 committed Nov 28, 2024
1 parent b34aba6 commit ab3158a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit ab3158a

Please sign in to comment.