Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-autopopulate

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-autopopulate - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

30

examples.md

@@ -81,2 +81,30 @@

## It has a couple caveats with projections
By default, Mongoose 5.x automatically projects in populated properties.
That means you need a little extra work to exclude autopopulated fields.
Either explicitly [deselect the path](https://mongoosejs.com/docs/api.html#query_Query-select)
in your projection, or set the [`selectPopulatedPaths` schema option](https://mongoosejs.com/docs/guide.html#selectPopulatedPaths)
to `false`.
```javascript
// Mongoose adds `members: 1` and `lead: 1` to the projection
let band = yield Band.findOne().select({ name: 1 });
assert.equal(band.members[0].name, 'Axl Rose');
assert.equal(band.lead.name, 'Axl Rose');
// You can also tell Mongoose to not project in populated paths by default
// using the `selectPopulatedPaths` schema option.
const newSchema = Band.schema.clone();
newSchema.options.selectPopulatedPaths = false;
let Band2 = mongoose.model('Band2', newSchema, 'bands');
band = yield Band2.findOne().select({ name: 1 });
assert.ok(!band.members);
assert.ok(!band.lead);
```
## It can specify an options argument

@@ -212,3 +240,3 @@

## It with `lean()`
## It requires an option to work with lean

@@ -215,0 +243,0 @@

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

0.9.1 / 2019-01-02
==================
* docs: add note about selectPopulatedPaths option #50
0.9.0 / 2018-11-08

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

3

package.json
{
"name": "mongoose-autopopulate",
"version": "0.9.0",
"version": "0.9.1",
"description": "Always populate() certain fields in your mongoose schemas",

@@ -28,2 +28,3 @@ "main": "index.js",

"co": "4.6.0",
"co-mocha": "1.2.2",
"mocha": "5.1.1",

@@ -30,0 +31,0 @@ "mongoose": "~5.3",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc