title: meteor findOne or find returns undefined
body: <p>I'm trying to do some validation prior to loading the main page. To do this I need to find a document that I have confirmed, exist in the Mongo Collection.  Unfortunately finding the document in the client.js doesn't seem to work. In my opinion the client and server collection are not in sync.  Based on similar articles i have read I made many changes without success.  Here is a quick summary of what I have tried.</p>
  
  <p>Option1: Try to find the record in the client side and not using auto-subscribe: record not found.</p>
  
  <p>In app.js</p>
  
  <pre><code>credentialToken = "2KcNCRzpTHzyZ1111";
  
  if (Meteor.isClient) {
    Template.hello.greeting = function () {
      return "Welcome to ares_sso.";
    };
  
    Meteor.startup(function () {    
      var results = Meteor.findrec(credentialToken);  
      console.log("results:",results); //results is undefined.
    });
  
    Template.hello.events({
      'click input': function () {
         if (typeof console !== 'undefined')
            console.log("You pressed the button");
       }
    });
  
  }
  
  if (Meteor.isServer) {
     Meteor.startup(function () {
     // code to run on server at startup
     });
  }
  </code></pre>
  
  <p>In /client/app.js</p>
  
  <pre><code>crs_collection = new Meteor.Collection("crs");
  Meteor.subscribe("crs");  
  
  Meteor.findrec = function(credentialToken) {
    target = {credentialtoken:credentialToken};
    recfound = crs_collection.findOne(target);
  
    //No luck with find either.
    //recfound = crs_collection.find({credentialtoken:credentialToken}, {limit:1}).fetch()[0];
    console.log("recfound:",recfound);  //returns recfound is undefined.
    return recfound;
  }
  </code></pre>
  
  <p>In /server/server.js</p>
  
  <pre><code>crs_collection = new Meteor.Collection("crs");
  
  Meteor.publish("crs", function(){
     return crs_collection.find();
  });
  </code></pre>
  
  <p>Option2: Next I did the find in the server side, using a method "server_recfind" which worked but I'm not able get the content to the client. </p>
  
  <p>In app.js</p>
  
  <pre><code>credentialToken = "2KcNCRzpTHzyZ1111";
  
  if (Meteor.isClient) {
    Template.hello.greeting = function () {
      return "Welcome to ares_sso.";
    };
  
    Meteor.startup(function () {    
       var results = Meteor.call('server_findrec',credentialToken); 
       console.log("results=",results); // also returns undefined
  
    });
  
    Template.hello.events({
      'click input': function () {
         if (typeof console !== 'undefined')
            console.log("You pressed the button");
       }
    });
  
  }
  
  if (Meteor.isServer) {
     Meteor.startup(function () {
     // code to run on server at startup
     });
  }
  </code></pre>
  
  <p>In /client/app.js</p>
  
  <pre><code>crs_collection = new Meteor.Collection("crs");
  Meteor.subscribe("crs");  
  </code></pre>
  
  <p>In /server/app.js</p>
  
  <pre><code>crs_collection = new Meteor.Collection("crs");
  
  Meteor.publish("crs", function(){
     return crs_collection.find();
  });
  
  // Using Sync which finds the record but how do I sent the content to the client?
  Meteor.methods ({
    'server_findrec': function(credentialToken) {
       // tried unblock but didnt work
       //this.unblock();
       var rec = crs_collection.findOne({'credentialtoken': credentialToken});
       console.log("INSIDE server findrec rec=",rec);  //shows content found
       // tried flush but it didn't do anything
       crs_collection.flush;
      return rec;  //rec not returning to the client
    }
  })
  </code></pre>
  
  <p>Option3: Frustrated and since I was able to find the document record with the server method. I tried adding global variables to delivery the content to the client side.  Unfortunately it didn't work</p>
  
  <p>In app.js</p>
  
  <pre><code>credentialToken = "2KcNCRzpTHzyZ1111";
  
  //added global variables
  c1 = '';
  c2 = '';
  c3 = ''
  
  if (Meteor.isClient) {
    Template.hello.greeting = function () {
      return "Welcome to ares_sso.";
    };
  
    Meteor.startup(function () {    
       var results = Meteor.call('server_findrec',credentialToken); 
       console.log("results=",results); // also returns undefined
       console.log("c1=",c1);
       console.log("c2=",c2);
       console.log("c3=",c3);  
    });
  
    Template.hello.events({
      'click input': function () {
         if (typeof console !== 'undefined')
            console.log("You pressed the button");
       }
    });
  
  }
  
  if (Meteor.isServer) {
     Meteor.startup(function () {
     // code to run on server at startup
     });
  }
  </code></pre>
  
  <p>In /client/app.js</p>
  
  <pre><code>crs_collection = new Meteor.Collection("crs");
  Meteor.subscribe("crs");  
  </code></pre>
  
  <p>In /server/app.js</p>
  
  <pre><code>crs_collection = new Meteor.Collection("crs");
  
  Meteor.publish("crs", function(){
     return crs_collection.find();
  });
  
  // Using Sync which finds the record but how do I sent the content to the client?
  Meteor.methods ({
   'server_findrec': function(credentialToken) {
  
       // tried unblock but didnt work
       //this.unblock();
  
       var rec = crs_collection.findOne({'credentialtoken': credentialToken});
       console.log("INSIDE server findrec rec=",rec);  //shows content found
       c1 = rec.cont1;
       c2 = rec.cont2;
       c3 = rec.cont3;
  
       //confirm that c1,c2 and c3 have content
       console.log(In server_findrec c1=",c); //shows content
       console.log(In server_findrec c2=",c2); //shows content
       console.log(In server_findrec c3=",c3); //shows content
  
       // tried flush to sync to client...didn't work
       crs_collection.flush;
  
       return rec;  //rec not returning to the client
    }
  })
  </code></pre>
  
  <p>There is a lot more code, so I have assembled all of the above hoping it gives you a clear picture of what I have tried and what I'm trying to do.  I'm sorry if I made a mistake in the process. </p>
  
  <p>Overall it will be great to know what am I doing wrong? I believe the 3 scenarios should work. Any help or recommendation will be appreciated.</p>
  
  <p>I'm using Meteor Release 0.7.1.2, no CoffeeScript.</p>
  
  <p>Thank you all</p>