Mongoose 独特的和填充的
在猫鼬身上有可能发生类似的事情吗Mongoose 独特的和填充的,mongoose,Mongoose,在猫鼬身上有可能发生类似的事情吗 User .findById(req.user) .populate({ path: "x"}) .populate({ path: "messages", match: { to: req.user}, select: "from date message" **distinct: "from"** }) .exec (function(e
User
.findById(req.user)
.populate({
path: "x"})
.populate({
path: "messages",
match: { to: req.user},
select: "from date message"
**distinct: "from"**
})
.exec (function(err, doc) {
}
如果不是,我如何才能在文档中仅获取不重复“发件人”的消息 我明白了:
User
.findById(req.user)
.populate({
path: "x"
})
.populate({
path: "messages",
match: { to: req.user},
select: "from date message"
})
.exec (function(err, doc) {
Message.distinct("from",doc.messages,function(err, doc) {
})
这迫使我重新进行查询。您是否能够将此链接到填充本身中?