Socket
Socket
Sign inDemoInstall

mongoose-lean-virtuals

Package Overview
Dependencies
165
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.1 to 0.9.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

0.9.0 / 2021-10-14
==================
* fix: set populate virtuals to `null` or `[]` if no results based on `justOne` for Mongoose 6 Automattic/mongoose#10816
0.8.1 / 2021-09-18

@@ -2,0 +6,0 @@ ==================

@@ -195,2 +195,3 @@ 'use strict';

}
const virtualType = schema.virtuals[virtual];
const sp = Array.isArray(virtual) ? virtual : virtual.split('.');

@@ -202,4 +203,16 @@ let cur = doc;

}
cur[sp[sp.length - 1]] = schema.virtuals[virtual].applyGetters(cur[sp[sp.length - 1]], doc);
let val = virtualType.applyGetters(cur[sp[sp.length - 1]], doc);
if (isPopulateVirtual(virtualType) && val === undefined) {
if (virtualType.options.justOne) {
val = null;
} else {
val = [];
}
}
cur[sp[sp.length - 1]] = val;
}
}
function isPopulateVirtual(virtualType) {
return virtualType.options && (virtualType.options.ref || virtualType.options.refPath);
}

4

package.json
{
"name": "mongoose-lean-virtuals",
"version": "0.8.1",
"version": "0.9.0",
"description": "Attach virtuals to the results of mongoose queries when using `.lean()`",

@@ -35,3 +35,3 @@ "main": "index.js",

"mocha": "5.2.x",
"mongoose": "^5.13.9"
"mongoose": "6.x"
},

@@ -38,0 +38,0 @@ "peerDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc