我正在建立一个教师和学生互动的应用程序。我试图发布教师/学生关系的课程。如何发布包含teacherUserId
和studentUserId
的类。
路径:publish.js
Meteor.publish('classes', function(group){
if (Roles.userIsInRole(this.userId, ['is_teacher'], group)) {
check(id, String);
return Classes.find({teacherUserId: this.userId, studentUserId: id});
} else {
// user not authorized. do not publish secrets
this.stop();
return;
}
});
路径:class.js
Template.classes.onCreated(function() {
var self = this;
self.autorun(function(){
self.subscribe('classes');
});
});
Template.classes.helpers({
studentProfileId: () => {
return FlowRouter.getParam('id');
}
});