2

i've found something strange and I look for explanations. In my meteor project, I have a file named collections.js which contains:

const Interventions = new Mongo.Collection('interventions');

(I want to use const to take the habit working with es6)

In my client/interventions.js, I want to get all interventions then I've wrote:

Template.interventions.helpers({
  interventions: function () {
    return Interventions.find({});    
  }
});

My interventions will never be pulled because of the const keyword ? If I remove it, I can get my data. Can you explain me why please ?

billyJoe
  • 2,034
  • 2
  • 24
  • 37

1 Answers1

1

That's because const limits scope of Interventions variable to collections.js file, so Interventions is not attached to window object, so it's not global and you can't use it in other files.

imkost
  • 8,033
  • 7
  • 29
  • 47