Hello,
My user collection looks like this:
{
emails: [{…}]
profile: {
firstName: "Faisal Ali",
lastName: "Sayyed",
pic: "s3Url",
gender: 'male',
products: []
createdAt: timeStamp
}
username: "FaisalAli19"
_id: "rCaB2GsNXNnc4bC3R"
}
I am trying to limit the user profile to this fields firstName, lastName, pic, and gender.
I tried the below publish methods but Meteor.user() still return all the fields.
Meteor.publish(null, function() {
if (!this.userId) return;
return Meteor.users.find(
{ _id: this.userId },
{
fields: {
"profile.pic": 1,
"profile.firstName": 1,
"profile.lastName": 1,
"profile.gender": 1
}
}
);
});
and
Meteor.publish('userData', function() {
if (!this.userId) return;
return Meteor.users.find(
{ _id: this.userId },
{
fields: {
"profile.pic": 1,
"profile.firstName": 1,
"profile.lastName": 1,
"profile.gender": 1
}
}
);
});
// on client side
Tracker.autorun(() => {
Meteor.subscribe('userData')
})
Any help will be appriciated thanks.