3.0.3 • Published 4 years ago

mongoose-populate v3.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Mongoose Populate

npm bundle size npm GitHub GitHub top language GitHub Workflow Status (branch)

Mini population hook for Mongoose so you don't need to keep rewriting this.populate and next.

Installation

$ npm install mongoose-populate

CommonJS

const { Schema } = require('mongoose')
const { createPopulateHook } = require('mongoose-populate')

ESM

import { Schema } from 'mongoose'
import { createPopulateHook } from 'mongoose-populate'

Schema

const ExampleSchema = new Schema({
    example: {
        type: Schema.Types.ObjectId,
        ref: 'OtherModel',
    },
})

Hook replacement

- ExampleSchema.pre('find', function populateExampleHook(next) {
-   this.populate('example');
-   next();
- });

+ ExampleSchema.pre('find', createPopulateHook('example'));
3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.1

5 years ago