我正在开发一个具有各种频道/房间的聊天应用程序,想要显示每个房间/频道的未读消息,我能够在所有参与者的活动房间显示未读消息,但不是全部客房。虽然新的消息在非活动的房间里,但不确定问题出在哪里,所以不执行辅助函数,感谢你的指针?感谢
'unReadCount':function(){
var currentuserid=Meteor.userId();
//updateChannelView
console.log("channelid and userid"+this._id + " " + currentuserid);
var res=channelViewLog.findOne({channelId:this._id,userId:currentuserid})
if(res){
var varlastviewed=new Date(res.lastViwed);
//console.log("last viewed timestamp"+varlastviewed + " " + this._id + " " + new Date());
var res1=Messages.find({channel:this._id,createdAt: {$gte:varlastviewed},user:{ $ne: currentuserid}}).count();
return res1;
}
}
Meteor.publish('PubChannelViewLog', function () {
var currentuserid=this.userId;
return channelViewLog.find({userId:currentuserid});
});