【发布时间】:2015-05-20 08:05:29
【问题描述】:
假设您有一个类似于以下的集合...
Tests = [
{
name: 'Some Test',
questions: [
{ question: 'Answer to life, the universe, and everything?', answer: '42' },
{ question: 'What is your favorite color?', answer: 'Blue' },
{ question: 'Airspeed velocity of unladen European Swallow?', answer: '24 mph' }
]
}
];
除了 answer 属性之外,您如何发布整个集合?
我了解您可以执行以下操作以从发布中省略属性...
Meteor.publish('tests', function() {
return Tests.find({}, {fields: {name:0}});
});
但我不确定如何从数组属性中省略一个属性。
谢谢!
【问题讨论】:
-
应该是
return Tests.find({}, {fields: {'questions.$.answer':0}});之类的,不过好像还不支持