【发布时间】:2017-03-27 20:20:00
【问题描述】:
我正在尝试在 Meteor 中创建搜索功能。我正在 Mongo 集合中搜索具有特定属性的项目。
我的过滤器是这样的反应变量:
this.canEnglish = new ReactiveVar(false);
this.canRussian = new ReactiveVar(false);
然后我尝试将这些反应变量用作集合上的过滤器。
Template.Search.helpers({
profiles: ()=> {
if(Template.instance().canEnglish.get()) {
return Meteor.users.find({'profile.grammarskills': 'english'});
} else if(Template.instance().canRussian.get()) {
return Meteor.users.find({'profile.grammarskills': 'russian'});
} else {
return Meteor.users.find();
}
}
});
过滤器正常工作,但我如何同时应用多个过滤器,例如在上面的代码中返回可以俄语和英语的人?
【问题讨论】:
标签: node.js mongodb meteor collections filter