Node.js 如何使用mongoose区分填充的集合
我有两本藏书,我想在所选的书中找到不同的主题(章节)Node.js 如何使用mongoose区分填充的集合,node.js,mongodb,express,mongoose,Node.js,Mongodb,Express,Mongoose,我有两本藏书,我想在所选的书中找到不同的主题(章节) 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)
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
你不能直接在mongoDB中使用它。使用外部过滤器。哪种过滤器!!你不能将distinct与populate一起使用,所以你应该制作自己的过滤器。好的,我明白了,谢谢