mongoosemongodb-querymongoose-schemamongoose-populatemongoose-plugins

Is exexPopulate() method is deprecated from the mongoose new version?


main()

    const main = async () =>{
    const task = await Task.findById('614ac31e103d9c5329d38686')
    await task.populate('owner').execPopulate()
    console.log(task.owner)
}

execPopulate() is not a function


Solution

  • From changelogs at https://mongoosejs.com/docs/migrating_to_6.html#removed-execpopulate,

    the line should be replaced to

    await task.populate('owner')