【发布时间】:2017-01-14 03:20:13
【问题描述】:
我有这个架构(简化)
post = new schema({
title: String,
items: [schema.Types.ObjectId]
});
image = new schema({
title: String,
header: String,
path: String
});
text = new schema({
title: String,
content: String
});
当我打电话时
postModel.findOne({
_id: ObjectId(req.body.page.id)
}).populate([
{
path: 'items',
model: 'image'
}, {
path: 'items',
model: 'text'
}
]).exec(function(err, article) {
return res.render('main/article', {
title: article.title,
items: article.items
});
});
结果只包含没有图像的文本。
但是,如果我填充它
.populate([
{
path: 'items',
model: 'text'
}, {
path: 'items',
model: 'image'
}
])
我只得到没有文字的图像。
这个问题好像只出现在windows上 我用: MongoDB 外壳版本:3.2.10 猫鼬:^4.6.4
【问题讨论】:
标签: node.js mongodb mongoose mongoose-populate