Meteor发布user.profile未显示在订阅上

时间:2015-12-07 09:46:41

标签: meteor meteor-publications

Meteor.publishComposite('jobs', {
    find: function() {
        var user = null;
        if (this.userId) {
            user = Meteor.users.findOne(this.userId);

            if ( user && user.profile && user.profile.isAdmin ) {
                return Jobs.find({}, { sort: { createdAt: -1 }});
            } else if(user && user._id) {
                return Jobs.find({'createdBy': user._id});
            } 
        } else {
            return this.ready();
        }
    },
    children: [
        {
            find: function(job) {
                // Find post author. Even though we only want to return
                // one record here, we use "find" instead of "findOne"
                // since this function should return a cursor.
                return Meteor.users.find(
                    {
                    _id: job.createdBy
                },
                {
                    fields: {
                        'profile': 1, 
                        'createdAt': 1
                    }
                }

                );
            }
        }
    ]
});

这是我在meteor-publishComposite包中使用的代码。出于某种原因,我没有在订阅中获得个人资料。我可以显示user.services,但不会显示user.profile

0 个答案:

没有答案