2015-09-05 139 views
0

我的目标是在路由器路径/ home2上的客户端发布3个用户的用户数据。路由器中的流星订阅

守则如下:

Meteor.publish "featured_talent", -> 
    console.log 'talent publishing:' 
    query = 
     'profile.picture': 
      $exists: true 
      $ne: null 
     'show_on_talent_view': true 
     'profile.roles.talent': true 

    options = 
     limit: 3 
     fields: 
      profile: 1 
     sort: 
      createdAt: -1 
    usr = Meteor.users.find query, options 
    return usr 

订阅在路由器上服务器

Router.map -> 
    @route "home2", 
     path: "/home2" 
     waitOn: -> 
      Meteor.subscribe "featured_talent" 

我没能获得在客户端的数据,这是我的出版物不工作!

+0

嗯,很明显变量'query'是不是在你的'服务器/ router.coffee'可用。如果你想定义一个全局变量,不要使用'var'或者你的情况,使用'@query = ...'。 –

+0

所以在我发表我用@query = 'profile.picture': $存在:真 $ NE:空 'profile.is_test': $ NE:真 'profile.is_featured':真 'profile.roles.talent':true 同样的错误! –

+0

我是流星的新手,所以如果你能再详细一点,那会是一大恩惠!谢谢 –

回答

0

在路由器下面的行query没有定义:

users: Meteor.users.find query, options