angularjs - Meteor.users subscribe only return current user -


i'm trying user username, when use meteor.users.findone, return current user. , if user meteor.users.find, returns current user document, , profile.firstname , profile.lastname of right matched username.

meteor.publish('userbyusername', function(username) {     return meteor.users.findone({         username: username     }, {         fields: {             'profile.firstname': 1,             'profile.lastname': 1,         }     }); }); 

how can user match username?

i think want not publish, method access particular username. publish/subscribe great datasets change - posts on stackoverflow, facebook feed, news articles, etc.

you looking first/last name of particular user, not change. want create server method returns first/last name of user. , can call method client access data.

if (meteor.isclient) {    //get username var   meteor.call('finduser', username, function(err, res) {     console.log(res.profile.firstname + " " + res.profile.lastname);   });  }  if (meteor.isserver) {    meteor.methods({     finduser: function(username) {       return meteor.users.findone({         username: username       }, {         fields: {           'profile.firstname': 1,           'profile.lastname': 1         }       });     }   });  } 

notice client meteor.call has callback method. db queries on meteor server asynchronous & non-blocking, need access result via javascript callback function.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -