1.0.5 • Published 2 years ago
mplode v1.0.5
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()