【问题标题】:Publish all user profiles using Meteor and Iron Router使用 Meteor 和 Iron Router 发布所有用户配置文件
【发布时间】:2015-01-21 07:21:57
【问题描述】:

我正在尝试仅发布用户个人资料信息,我将在成员目录中使用这些信息。这是我目前正在做的(自动发布已被删除):

// server/publications.js

Meteor.publish("usersListing", function() {
  return Meteor.users.find({}, {profile:1});
});


// routes.js (located in project root)

this.route('users', {
  path: '/users',
  waitOn: function () {
    return Meteor.subscribe("usersListing");
  },
  data: {
    users: Meteor.users.find({})
  }
});

这为我提供了所有注册用户的所有用户信息,包括服务(散列密码等)。我想将客户端上可访问的数据仅限于配置文件字段。任何帮助将不胜感激。

【问题讨论】:

    标签: meteor iron-router


    【解决方案1】:

    您已经接近了 - 在 find 选项中,您需要指定您正在限制 fields,如下所示:

    Meteor.users.find({}, {fields: {profile: 1}});
    

    有关详细信息,请参阅field specifiers documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-17
      • 2014-06-01
      • 2014-06-05
      • 2016-10-31
      • 2023-03-30
      • 1970-01-01
      • 2023-03-12
      • 2014-05-07
      相关资源
      最近更新 更多