Possible to populate two levels?

后端 未结 2 1647
故里飘歌
故里飘歌 2021-01-24 13:14

Say I have collections/documents like below:

question collection:

{
   _id: ObjectId(\"0000\"),
   title: \"test question\",
   survey: ObjectId(\"1234\"         


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-24 13:50

    I guess the best is to nest in the top populate and make it as a object

     Court.
      findOne({ name: 'Val' }).
      populate({
        path: 'events',
        populate: { path: 'authorId' }
      }); 

    http://mongoosejs.com/docs/populate.html#deep-populate

提交回复
热议问题