Console.log a custom User field


#1

I first need to check if an array [votes] exists before inserting more data.

Here is the json structure :

{
    "_id" : "pziqjwGCd2QnNWJjX",
    "createdAt" : ISODate("2017-12-21T22:06:41.930Z"),
    "emails" : [ 
        {
            "address" : "test@test.com",
            "verified" : false
        }
    ]
    "votes" : [ 
        {
            "ZyYZ4LDTaeWNMN9eE" : "yes"
        }
    ]

}

let votes = Meteor.userId().votes returns undefined.

How can I return the [votes] array ?


#2

Hi,
Meteor.userId() return the user id if logged. If u want the user document, u need to use Meteor.user().
Check also the docs if u want to know more.


#3

ALright thank you, doing so it returns the object but not that particular field. Is there a way to target the field like Meteor.user().votes ?


#4

Check the Meteor Guide on this topic.