Reputation: 3
I apologize for such a simple question, but documentation meteor.js very briefly, many of the points are not described in great detail. How to access the elements of the collection in the meteor? Suppose there is a built collection of User, which stores user data. The user ID can be obtained by applying the following code on the client side:
return Meteor.userId()
However, but if you want to display other data (username, email), it is already a problem. After about such code issued inscription [object Object]:
return Meteor.users.find({emails:"[email protected]"})
What is the correct syntax to access elements of the collection that I have missed?
Upvotes: 0
Views: 505
Reputation: 1881
If you want to display data from person who is logged in you have Meteor.user() object where all values are hidden, use it like :Meteor.user().username
or so, for person who isn't logged but you have her username for example
Meteor.users.findOne({username:<username>}).some_data
or
Meteor.users.find({username:<username>}).fetch()[0].some_data
Of course first one is better to use
Upvotes: 2