Mongoose populate with array of objects containing ref

前端 未结 4 593
旧巷少年郎
旧巷少年郎 2020-12-07 10:39

I have a Mongoose schema with an array lists of objects that consist of a reference to another collection and a nested array of numbers:

var Sch         


        
4条回答
  •  误落风尘
    2020-12-07 10:57

    Actual answer:

    Use this,

    populate('lists.list')
    

    Extra:

    Here are lists are an array of objects (list). In JS you can access this like that,

    console.log(lists.list);
    

    and MongoDB syntax is 99% similar to JS syntax. so you can also populate this using lists.list.

提交回复
热议问题