我有Category
模型:
Category:
...
articles: [{type:ObjectId, ref:'Article'}]
文章模型包含参考Account model
。
Article:
...
account: {type:ObjectId, ref:'Account'}
因此,填充articles
类别模型将是:
{ //category
articles: //this field is populated
[ { account: 52386c14fbb3e9ef28000001, // I want this field to be populated
date: Fri Sep 20 2013 00:00:00 GMT+0400 (MSK),
title: 'Article 1' } ],
title: 'Category 1' }
问题是:如何填充填充字段([文章])的子字段(帐户)?这是我现在的做法:
globals.models.Category
.find
issue : req.params.id
null
sort:
order: 1
.populate("articles") # this populates only article field, article.account is not populated
.exec (err, categories) ->
console.log categories
我知道这里讨论过:猫鼬:填充填充字段,但没有找到真正的解决方案