我有 2 个合集,我想在选定的书中获得不同的主题(章节)
Books={title:string, Chaps:Chapters, date:date}
Chapters= {title:string, subject:string}
如何使用
books.find(id:"5455545").populate('Chaps').distinct('Chaps.subject').exec(function (er,data){
console.log(data)
})
// i got this result => [] empty array
答案 0 :(得分:1)
你不能直接在 mongoDB 中使用它。使用外部过滤器。