The documentation for using a mongo collection is as follows:
Chatrooms = new Mongo.Collection(“chatrooms”);
I just wonder that if that collection is only used within that server js file - would the following be better?
var Chatrooms = new Mongo.Collection(“chatrooms”);
My reasoning (but I could be totally wrong!) is that by using the var word you make the application more secure - the collection is only available in the one js file, and I also suspect it might be more memory efficient than having a global varable.
The problem with this approach is that by using var, const, let you are scoping the collection to the file. That means that if (as is most likely) you intend using the collection on the client and server, you are constrained to distinguishing the context by means of Meteor.isClient and Meteor.isServer.
From a security perspective this is a bad idea, because all your code within a Meteor.isServer is sent to the client and may be inspected by anyone.