Meteor - 基于startDate和endDate发布用户

时间:2016-03-01 04:39:19

标签: meteor

我试图发布在两个日期范围之间拥有有效帐户的所有用户。我的代码似乎没有工作,有什么想法吗?

Meteor.publish('classAuction', function (group) {
  if (Roles.userIsInRole(this.userId, ['is_teacher'], group)) {

    var users = Meteor.users.find({roles:'is_student', "accountStatus.isUserAccountActive": true}); // Get active candidates

    var today = new Date().toDateString();
    var startDate = Date(accountStatus.startDate).toDateString();


    if (today >= startDate) {
      return Meteor.users.find({});
    } else {

    // user not authorized. do not publish secrets
    this.stop();
    return;
  }
}
});

1 个答案:

答案 0 :(得分:1)

您可以使用mongo查询,例如:

var today = new Date();

return Meteor.users.find({
    "accountStatus.startDate": { $gte: today},
    roles:'is_student',
    "accountStatus.isUserAccountActive": true
});