mplode
v1.0.5
Published
A helper function for the mongoose populate function
Downloads
37
Maintainers
Readme
Introduction
The purpose of this package is to simplify the use of the populate method in mongoose. The populate method is used to ensure any references in a document are resolved to actual documents.
Before
The Mongoose populate method is usually used like this
const documents = await interactions
.find(args)
.populate('user')
.populate({ path: 'nft', populate: { path: 'wallet', populate: 'user' } })
.lean()After
With the use of this helper package this becomes:
import { expand } from 'mplode'
const documents = await interactions
.find(args)
.populate(expand('user'))
.populate(expand('nft.wallet.user'))
.lean()