Skip to content

Instantly share code, notes, and snippets.

@RubenHoms
Created November 8, 2013 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RubenHoms/7371300 to your computer and use it in GitHub Desktop.
Save RubenHoms/7371300 to your computer and use it in GitHub Desktop.
Odd Meteor behaviour
// I'm trying to run a query on Mongo, which should simply be:
var res = Toggl.findOne({ date: new Date().getDateString() } );
// Although when I run that piece of code Meteor exits with the message: "Exited with code: 1"
// So I try other methods to run this statement, such as:
var getTasks = Meteor.bindEnvironment( function() {
return Toggl.findOne({ date: new Date().toDateString() } );
}, function( err ) {
console.log( err );
});
console.log(getTasks());
// Running this gives me the error [ReferenceError: Toggl is not defined], which is odd since I can use the collection variable just fine within other functions.
// I have declared my collections in a file called database.js located in the root directory as "Toggl = new Meteor.Collection( "toggl" )
// so that it's available in the global scope. Anyway I thought to work around by doing the following:
var Toggl = new Meteor.Collection( "toggl" );
var getTasks = Meteor.bindEnvironment( function() {
return Toggl.findOne({ date: new Date().toDateString() } );
}, function( err ) {
console.log( err );
});
console.log(getTasks());
// This time I am getting back a document which is logged to the console but Meteor still exits with "Exited with code: 1".
// Magnets, how do they work!?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment