I cant find information on how to console log a document field (array) name
console.log(entry.friends.status); <- Dont work
var thefriends = Friends.find({ _id: Meteor.userId() }).fetch();
console.log(thefriends.friends);
let myCount = 0
let inviteCount;
thefriends.forEach(function(entry) {
console.log(entry.friends[status]);
if (entry.friends.status == 2) {
myCount +1
}
});
console.log(myCount);
DB: friends
{
"_id" : "8YBhc3AeKbfHaoNJ9",
"friends" : [
{
"id1" : "Nt4ZTwqAqKfNo3avi",
"id2" : "8YBhc3AeKbfHaoNJ9",
"status" : 2
},
{
"id1" : "sQEAn5HiCtEnWXHPs",
"id2" : "8YBhc3AeKbfHaoNJ9",
"status" : 1
},
{
"id1" : "FXsCRBoPveGN6XvbJ",
"id2" : "8YBhc3AeKbfHaoNJ9",
"status" : 2
},
{
"id1" : "3D5sGHGSWHrmTKc4t",
"id2" : "8YBhc3AeKbfHaoNJ9",
"status" : 2
}
]
}