title: Meteor filter collection
body: <p>I'm trying to secure accessing a specific collection but I'm having troubles doing it. I have no problems disabling the insert, update and delete with the <code>Collection.allow()</code> map.</p>
  
  <p>The problem is that I also want to filter the results returned by the <code>Collection.find()</code> and <code>Collection.findOne()</code> function. I read about the <code>Meteor.publish()</code> and <code>Meteor.subscribe()</code> stuff, but somehow I cannot make it work (it's not getting filtered, I just can see all the results).</p>
  
  <p>In my server-code I do the following:</p>
  
  <pre><code>Groups = new Meteor.Collection("groups");
  Meteor.publish("myGroups", function() {
      if (Functions.isAdmin(userId)) {
          return Groups.find({
              sort: {
                  name: 1
              }
          }); 
      }
  });
  </code></pre>
  
  <p>The function I'm using really works (so it's not that it's always returning <code>true</code>).</p>
  
  <p>In the client-code I wrote the following:</p>
  
  <pre><code>Meteor.subscribe("myGroups");
  Groups = new Meteor.Collection("groups");
  </code></pre>
  
  <p>Now when I do <code>Groups.find{});</code> at the client I still get all results (and I should get no result).</p>
  
  <p>Am I misunderstanding something or doing something wrong? I could of course make the collection completely server-side and use <code>Meteor.methods()</code> and <code>Meteor.call()</code> to get the collection data (so that it's always encapsulated by the server). But I really thought it would be cool that I didn't have to do that.</p>
  
  <p>Also I wonder why this can't be done on the same level as insert/update/remove with <code>Collection.allow()</code>. I mean, it would be could that we could have the possibility to add a filter to the map for reading data through find/findOne.</p>