Hello there, how can I subscribe to a custom user field ?
Here is the JSON format for Meteor.users collection in the DB
{
"_id" : "pziqjwGCd2QnNWJjX",
"createdAt" : ISODate("2017-12-21T22:06:41.930Z"),
"emails" : [
{
"address" : "email@email.com",
"verified" : false
}
]
"votes" : {
"laws" : [
{
"ZyYZ4LDTaeWNMN9eE" : "oui"
}
]
}
}
PUBLICATION
Meteor.publish("UserVotes", () => {
if (!this.userId) return null;
return Meteor.users.find(this.userId, { fields: [votes] });
});
SUBSCRIPTION
export default createContainer(params => {
Meteor.subscribe("UserVotes");
return Meteor.users.find(this.userId, {
fields: {
votes: 1
}
});
}, UserVotes);
It returns users.find is not an object, any idea?