{"action":"created","issue":{"url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/76","labels_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/76/comments","events_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/76/events","html_url":"https://github.com/jagi/meteor-astronomy/issues/76","id":102546596,"number":76,"title":"Calling server method from client","user":{"login":"tdamsma","id":7870803,"avatar_url":"https://avatars.githubusercontent.com/u/7870803?v=3","gravatar_id":"","url":"https://api.github.com/users/tdamsma","html_url":"https://github.com/tdamsma","followers_url":"https://api.github.com/users/tdamsma/followers","following_url":"https://api.github.com/users/tdamsma/following{/other_user}","gists_url":"https://api.github.com/users/tdamsma/gists{/gist_id}","starred_url":"https://api.github.com/users/tdamsma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdamsma/subscriptions","organizations_url":"https://api.github.com/users/tdamsma/orgs","repos_url":"https://api.github.com/users/tdamsma/repos","events_url":"https://api.github.com/users/tdamsma/events{/privacy}","received_events_url":"https://api.github.com/users/tdamsma/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-22T15:59:13Z","updated_at":"2015-08-22T20:43:00Z","closed_at":null,"body":"How can I add a method to a class that runs on the server, but is called from the browser? \r\nFor example: I have a class users and posts, and I want to return the count for the number of posts per user. So I add the method as follows:\r\n\r\n    methods: \r\n      countPosts: -> Posts.find({userId: this._id}).count()\r\n\r\nOn the server this returns the correct result but on the client, I am only subscribed to a subset of the posts, so the result is not correct. How can I get the correct count for this method on the client?"},"comment":{"url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/comments/133752623","html_url":"https://github.com/jagi/meteor-astronomy/issues/76#issuecomment-133752623","issue_url":"https://api.github.com/repos/jagi/meteor-astronomy/issues/76","id":133752623,"user":{"login":"tdamsma","id":7870803,"avatar_url":"https://avatars.githubusercontent.com/u/7870803?v=3","gravatar_id":"","url":"https://api.github.com/users/tdamsma","html_url":"https://github.com/tdamsma","followers_url":"https://api.github.com/users/tdamsma/followers","following_url":"https://api.github.com/users/tdamsma/following{/other_user}","gists_url":"https://api.github.com/users/tdamsma/gists{/gist_id}","starred_url":"https://api.github.com/users/tdamsma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdamsma/subscriptions","organizations_url":"https://api.github.com/users/tdamsma/orgs","repos_url":"https://api.github.com/users/tdamsma/repos","events_url":"https://api.github.com/users/tdamsma/events{/privacy}","received_events_url":"https://api.github.com/users/tdamsma/received_events","type":"User","site_admin":false},"created_at":"2015-08-22T20:43:00Z","updated_at":"2015-08-22T20:43:00Z","body":"Thanks for the quick reply! Too bad I can't keep the code with the class definition. Do you see a way to abstract this away? Would be cool if I could just add a serverMethod to my class and that all this is then taken care of. But I think you have enough stuff to add already. Looking forward to the next release, keep up the good work! "}}