在 MEAN 环境中,我使用以下 mongoose 查询来查找并输出特定作者及其相应的书籍。
Author
.findOne({personcode: code})
.select('-_id')
.select('-__v')
.populate('bookids') //referencing to book documents in another collection (->array of bookids)
.select('-_id') //this doens't affect the data coming from the bookids-documents
.select('-__v') //this doens't affect the data coming from the bookids-documents
.exec(function (err, data) {
//foo
});
我也想从外部文档中排除“_id”和“__v”字段的填充数据。如何实现?
Author .findOne({personcode: code}) .select('-_id -__v') .populate('bookids shelfId rowId', '-_id -__v') .exec(function (err, data) { //foo });
- Shubham Shaw