流星发布:隐藏数组文档字段中的某些字段? [英] Meteor publication: Hiding certain fields in an array document field?
本文介绍了流星发布:隐藏数组文档字段中的某些字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含以下文档的集合:
I have a collection with documents like this:
{
_id: af3F3afafaa,
firstName: "John",
family: [{name: "David", relation: "brother", alive: true},
{name: "Susan", relation: "mother", alive: false}]
}
有没有办法编写一个隐藏家庭字段数组中的字段的出版物?因此,如果我订阅了该出版物,我会得到:
Is there a way to write a publication that hides a field in the family field array? So if I subscribed to the publication I would get:
{
_id: af3F3afafaa,
firstName: "John",
family: [{name: "David", alive: true},
{name: "Susan", alive: false"}]
}
推荐答案
根据Meteor docs,这样的事情可以工作:
According to the Meteor docs, something like this could work:
Meteor.publish('family', function(famId) {
return Families.find(famId, {
fields : {
"family.relation" : 0 //Exclude family.relation from the sent data
}
});
});
这篇关于流星发布:隐藏数组文档字段中的某些字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文