2
main()

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

execPopulate() is not a function

MD. RAKIB HASAN
  • 3,670
  • 4
  • 22
  • 35

2 Answers2

3

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

the line should be replaced to

await task.populate('owner')
Francis.TM
  • 1,761
  • 1
  • 18
  • 19
0

execPopulate() has been removed in latest version of mongoose , the code can only work if using oder version which is not advisable due to deprecation

Just remove the execPopulate and keep task.populate('owner')