流星发布异常:使用 aldeed:tabular 时未在发布期间检查()所有参数
Meteor publication Exception: Did not check() all arguments during publisher when using aldeed:tabular
我有以下出版物:
Meteor.publish( 'usersadmin', function() {
return Meteor.users.find( {}, { fields: { "emails": 1, "roles": 1, "profile": 1 } } )
});
并且我在以下 table 中使用 aldeed:tabular 显示该出版物:
TabularTables.UsersAdmin = new Tabular.Table({
name: "User List",
collection: Meteor.users,
pub: "usersadmin",
allow: function(userId) {
return Roles.userIsInRole(userId, 'admin');
},
columns: [{
data: "emails",
title: "Email",
render: function(val, type, doc) {
return val[0].address;
}
}, {
data: "roles",
title: "Roles",
render: function(val, type, doc) {
return val[0]._id;
}
}]);
table 显示正常,但在服务器端出现以下异常:
Exception from sub usersadmin id 2d7NFjgRXFBZ2s44R Error: Did not check() all arguments during publisher 'usersadmin'
这是什么原因造成的?
您收到此错误是因为您需要使用 check(value, pattern)
.
检查传递给 usersadmin
发布函数的参数
在aldeed:tabular
包中实现的响应式数据表,将参数tableName
、ids
和fields
传递给发布功能;这就是抛出异常的原因。
根据documentation,您需要满足以下要求:
Your function:
- MUST accept and check three arguments: tableName, ids, and fields
- MUST publish all the documents where _id is in the ids array.
- MUST do any necessary security checks
- SHOULD publish only the fields listed in the fields object, if one is provided.
- MAY also publish other data necessary for your table
这应该可以修复错误:
Meteor.publish('usersadmin', function(tableName, ids, fields) {
check(tableName, String);
check(ids, Array);
check(fields, Match.Optional(Object));
return Meteor.users.find({}, {fields: {"emails": 1, "roles": 1, "profile": 1}});
});
我有以下出版物:
Meteor.publish( 'usersadmin', function() {
return Meteor.users.find( {}, { fields: { "emails": 1, "roles": 1, "profile": 1 } } )
});
并且我在以下 table 中使用 aldeed:tabular 显示该出版物:
TabularTables.UsersAdmin = new Tabular.Table({
name: "User List",
collection: Meteor.users,
pub: "usersadmin",
allow: function(userId) {
return Roles.userIsInRole(userId, 'admin');
},
columns: [{
data: "emails",
title: "Email",
render: function(val, type, doc) {
return val[0].address;
}
}, {
data: "roles",
title: "Roles",
render: function(val, type, doc) {
return val[0]._id;
}
}]);
table 显示正常,但在服务器端出现以下异常:
Exception from sub usersadmin id 2d7NFjgRXFBZ2s44R Error: Did not check() all arguments during publisher 'usersadmin'
这是什么原因造成的?
您收到此错误是因为您需要使用 check(value, pattern)
.
usersadmin
发布函数的参数
在aldeed:tabular
包中实现的响应式数据表,将参数tableName
、ids
和fields
传递给发布功能;这就是抛出异常的原因。
根据documentation,您需要满足以下要求:
Your function:
- MUST accept and check three arguments: tableName, ids, and fields
- MUST publish all the documents where _id is in the ids array.
- MUST do any necessary security checks
- SHOULD publish only the fields listed in the fields object, if one is provided.
- MAY also publish other data necessary for your table
这应该可以修复错误:
Meteor.publish('usersadmin', function(tableName, ids, fields) {
check(tableName, String);
check(ids, Array);
check(fields, Match.Optional(Object));
return Meteor.users.find({}, {fields: {"emails": 1, "roles": 1, "profile": 1}});
});