# mongoose-power-populate

> "Join" mongoose documents. Recursively populate document references in either direction.

Latest version **1.3.4** (published 2015-09-15) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install mongoose-power-populate
pnpm add mongoose-power-populate
yarn add mongoose-power-populate
bun add mongoose-power-populate
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.3.4 |
| Published | 2015-09-15 |
| First published | 2015-07-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Alex Mingoia |
| Maintainers | buildingconnected, alexmingoia |
| Keywords | mongoose, populate, join, mongoose-deep-populate, mongoose-reverse-populate |

## Links

- npm: https://www.npmjs.com/package/mongoose-power-populate
- Repository: https://github.com/alexmingoia/mongoose-power-populate
- Issues: https://github.com/alexmingoia/mongoose-power-populate/issues
- npm.io page: https://npm.io/package/mongoose-power-populate

## Dependencies (2)

- [get-object-path](https://npm.io/package/get-object-path.md) 0.0.2
- [object-path-set](https://npm.io/package/object-path-set.md) 0.0.1

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.3.4 (latest) — 2015-09-15
- 1.3.3 — 2015-09-08
- 1.3.2 — 2015-09-08
- 1.3.1 — 2015-09-08
- 1.3.0 — 2015-08-18
- 1.2.0 — 2015-08-03
- 1.1.3 — 2015-07-27
- 1.1.2 — 2015-07-13
- 1.1.1 — 2015-07-09
- 1.1.0 — 2015-07-07
- 1.0.0 — 2015-07-06

## README

# mongoose-power-populate

> "Join" mongoose documents. Recursively populate document references
> in either direction.

**DEPRECATED**: Use Mongoose 4+ and
[mongoose-populate-virtuals](https://github.com/alexmingoia/mongoose-populate-virtuals)
instead.

## Usage

Wrap mongoose to provide an improved `populate()` method:

```javascript
var mongoose = require('mongoose');
var populatePlugin = require('mongoose-power-populate')(mongoose);
```

Populate paths with predefined options:

```javascript
Book.find().populate('author reviews').exec(...);
```

Specify options for population paths on the model:

```javascript
BookSchema.plugin(populatePlugin, {
    author: {
      ref: 'User',
      foreignKey: '_id',
      localKey: 'authorId',
      select: 'name',
      lean: true,
      singular: true
    }
});
```

Populate nested paths:

```javascript
User
  .find(...)
  .populate({
    'posts': { ... },
    'posts.comments': { ... }
  })
  .exec(...);
```

Override options at query time:

```javascript
Book
  .find()
  .populate({
    author: {
      select: 'name isbn'
    }
  })
  .exec(...);
```


Populate existing documents:

```javascript
Book.populate(docs, 'author', callback);
```

### Options

- `ref` Name of the mongoose model.
- `foreignKey` Key on the model of the populated subdocuments.
- `localKey` Key on the model being populated.
- `singular` Whether to return a single result or an array of results.
- `lean` Whether to populate with models or plain objects.
- `query` Specify the `find()` query used to fetch related documented.
- `select` Passed to mongoose's `.select()`.

---
_Source: https://npm.io/package/mongoose-power-populate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
