我有 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' }
问题是: 如何填充已填充字段([文章])的子字段(account) :
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
我知道这里讨论过: 猫鼬: 居住在人口稠密的地区,但是没有找到真正的解决方案