Photos.count not getting displayed


#1

i want to display to the users how many photos he has uploaded, count of the photos

when users upload there photos i have collection called photos

{
"_id" : “WjEBRDDiXLNx36BxX”,
“userId” : “sNdWo3ysT9dFDD2fZ”,
“imgpath” : “/cfs/files/images/SX2BzrXct35qBT86n”
}

/* 2 */
{
"_id" : “gTaFGZ52XMMb2pHPe”,
“userId” : “sNdWo3ysT9dFDD2fZ”,
“imgpath” : “/cfs/files/images/dcQCpXXkMjEPfHtwR”
}

i also have published the collection
Meteor.publish(“photos”, function () {
return Photos.find();
});

i have wrote an helper function in .js
Template.uploadImage.helpers({
photocountmem:function(){
alert(Meteor.userId());
alert(Photos.find({“userId”:Meteor.userId()}).count());

 return Photos.find({"userId":Meteor.userId()}).count();
}

});

inspite of 2 photos it still shows 0

what can be wrong with it?

it shows zero when i do this
alert(Photos.find().count());


#2

Do you have a subscription for the photos?


#3

thanks i figured it out that subscription was required, but i did passed in the router data function
it worked
i added subscription for photos
and it worked