流星发布:隐藏数组文档字段中的某些字段?
Meteor publication: Hiding certain fields in an array document field?
我有一个 collection 文件是这样的:
{
_id: af3F3afafaa,
firstName: "John",
family: [{name: "David", relation: "brother", alive: true},
{name: "Susan", relation: "mother", alive: false}]
}
有没有办法写一个隐藏家庭字段数组中的字段的发布?因此,如果我订阅该出版物,我将获得:
{
_id: af3F3afafaa,
firstName: "John",
family: [{name: "David", alive: true},
{name: "Susan", alive: false"}]
}
根据 Meteor docs,类似这样的方法可行:
Meteor.publish('family', function(famId) {
return Families.find(famId, {
fields : {
"family.relation" : 0 //Exclude family.relation from the sent data
}
});
});
我有一个 collection 文件是这样的:
{
_id: af3F3afafaa,
firstName: "John",
family: [{name: "David", relation: "brother", alive: true},
{name: "Susan", relation: "mother", alive: false}]
}
有没有办法写一个隐藏家庭字段数组中的字段的发布?因此,如果我订阅该出版物,我将获得:
{
_id: af3F3afafaa,
firstName: "John",
family: [{name: "David", alive: true},
{name: "Susan", alive: false"}]
}
根据 Meteor docs,类似这样的方法可行:
Meteor.publish('family', function(famId) {
return Families.find(famId, {
fields : {
"family.relation" : 0 //Exclude family.relation from the sent data
}
});
});