Mongoose populate doesn't seem to work. I've been confused for two days.

problem description

mongoose populate doesn"t seem to work. Confusingly, I use it in another part of the project, and it"s normal

.

the environmental background of the problems and what methods you have tried

mongodb: 4.0.1
mongoose: 5.2.9

related codes


router.get("/test", async (ctx, next) => {
  const result = await DinnerModel.find().populate({
    path: "foods"
  })
  ctx.result = {
    code: 200,
    data: {
      list: result,
      msg: "success"
    }
  }
  await next()
})

what result do you expect? What is the error message actually seen?

What is the cause of

?

May.15,2021

const result = await DinnerModel.find().populate({
    path: "foods"  // =>  path: "content" 
})
Menu