2016-03-01 47 views
0

我试图发布在两个日期范围之间拥有活动账户的所有用户。我的代码似乎没有工作,有什么想法?流星 - 基于startDate和endDate发布用户

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

也,查询似乎没有根据日期查询? –

+0

好的。我尝试了其他的东西,仍然没有工作(见上文)。我更接近这个工作,或者我离它很近。 – bp123

回答

1

你可以使用这个蒙戈查询,像:

var today = new Date(); 

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

谢谢@Arcnon。我只是试过这个,它的工作原理。谢谢! – bp123