當我console.log當前從服務器端登錄的用戶時,我看到所有字段。當我從客戶端執行同樣的操作時,我只能看到_id和email字段。我很確定我訂閱正確。並非所有在流星中調用的Mongo字段
Accounts.onCreateUser(function(options, user){
user.subreddits = [];
console.log(user);
return user;
});
Meteor.publish('users', function(){
return Meteor.users.find().fetch();
});
SinglePost = React.createClass({
getInitialState: function(){
Meteor.subscribe('users');
return {
};
},
deletePost: function(){
var post_to_delete = {_id: this.props.id}
Posts.remove(post_to_delete);
},
showMeInfo: function(){
console.log(Meteor.user());
},
render: function(){
return (
<div>
<li>
<button onClick={this.deletePost}> Click Me!</button> {this.props.title}: {this.props.content}
</li>
<p><button onClick={this.showMeInfo}> Show Me Info! </button> </p>
</div>
);
}
});
我如何能夠讀取和寫入用戶的屬性版(Subreddit)? – ChrisWilson
你必須把它放在用戶['profile'] –
更新的答案用於保存'user ['profile']' –