Would u have an example of how to publish the users email to make it available for query on the client?
Just do something like this (not debugged) on server:
Meteor.publish('allUsers', function() {
return Meteor.users.find({});
});
And client:
Meteor.subscribe('allUsers');
But like I said: DO NOT DO THIS UNSAFE UNSECURE AND BAD EXAMPLE
So, to give a good example also:
Untested, just to show you the concept with some comments:
Run only on server:
Meteor.users.after.update(function (userId, doc, fieldNames, modifier, options) {
// Only update when the user is logged in
if(!userId) {
return;
}
// check to see if the name was changed
if(modifier.$set && modifier.$set.name && this.previous.name !== modifier.$set.name) {
// name changed
// So update your articles which have this users name
Articles.update({
// Find them by the userId active
author.id = userId
},{
$set: {
// and update the name
'author.name': modifier.$set.name,
},
});
}
});
Now every time the user is logged in and updates his name there will be an update statement on all your articles, your collection, and it will update all names. You donāt need to do anything custom for that except this piece.
btw this uses that plugin I mentioned: https://github.com/matb33/meteor-collection-hooks
When you insert a new article you can do this:
Articles.before.insert(function (userId, doc) {
doc.author.name = Meteor.users.findOne(userId).name;
});
Then you will start directly with the name of the current user so you also donāt have to think about that anymore when you create forms to insert the article in the collection.