【问题标题】:Publishing role names into a table Meteor alanning:roles and aldeed:tabular将角色名称发布到表 Meteor alanning:roles 和 aldeed:tabular
【发布时间】:2016-02-05 04:09:26
【问题描述】:

我无法在表格中显示创建的角色。我正在使用 alanning:roles 和 aldeed:tabular。要创建我有的表:

TabularTables.RolesAdmin = new Tabular.Table({
   name: "Roles",
   collection: Meteor.roles,
   pub:"rolesadmin",
   allow: function (userId) {
     return Roles.userIsInRole(userId, 'admin');
   },
   columns: [
     { 
       data: "name",
       title: "Role Name",
     },
   ],
});

出版物看起来像这样:

Meteor.publish( 'rolesadmin', function() {
  return Meteor.roles.find( {}, { fields: { "name": 1 } } );
});

运行应用程序时,表格仅显示“处理中...”,因此出现错误,无法访问/查找数据?

我在服务器终端中遇到以下异常:

Exception from sub rolesadmin id 6c6x3mDzweP8MbB9A 
Error: Did not check() all arguments during publisher 'rolesadmin'

如果我签入 mongo db.roles.find(),则没有 6c6x3mDzweP8MbB9A id 的角色。这个错误指的是什么?

【问题讨论】:

    标签: meteor user-roles


    【解决方案1】:

    来自meteor-tabular docs

    要告诉 Tabular 使用您的自定义发布功能,请传递 发布名称作为 pub 选项。你的功能:

    必须接受并检查三个参数:tableName、ids 和 fields

    必须发布 _id 在 ids 数组中的所有文档。

    必须进行任何必要的安全检查

    如果提供了,则应仅发布字段对象中列出的字段。

    还可以发布您的表格所需的其他数据

    因此,您似乎需要适当地考虑文档中提到的这三个参数。不过,根据您发布的内容,我不确定您是否真的需要一个自定义 pub。

    【讨论】:

    • 谢谢!你说的对。我不需要 Meteor.roles 的自定义出版物。
    • 太棒了,很高兴听到它!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 2020-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多