流星发布异常:在使用 aldeed:tabular 时,在发布过程中没有检查() 所有参数

Meteor publication Exception: Did not check() all arguments during publisher when using aldeed:tabular

本文关键字:过程中 参数 检查 异常 布异常 流星 tabular aldeed      更新时间:2023-09-26

我有以下出版物:

Meteor.publish( 'usersadmin', function() {
  return Meteor.users.find( {}, { fields: { "emails": 1, "roles": 1, "profile": 1 } } )
});

我使用 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;
        }
      }]);

该表显示正常,但在服务器终端中显示以下异常:

 Exception from sub usersadmin id 2d7NFjgRXFBZ2s44R Error: Did not check() all arguments during publisher 'usersadmin'

这是什么原因造成的?

会收到此错误,因为您需要使用 check(value, pattern) 检查传递给 usersadmin 发布函数的参数。

aldeed:tabular 包中实现的响应式 DataTable 将参数tableNameidsfields传递给发布函数;这就是引发异常的原因。

根据文档,您需要满足以下要求:

您的职能:

  • 必须接受并检查三个参数:表名、ID 和字段
  • 必须发布 ids 数组中_id所在的所有文档。
  • 必须进行任何必要的安全检查
  • 应仅发布字段对象中列出的字段(如果提供了)。
  • 还可以发布您的表格所需的其他数据

这应该可以修复错误:

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}});
});