i defined a array "userCollections" without var in my lib folder, fill this with new Collections:
userCollections = [];
Collectionlist = CustomCollections.find({});
Collectionlist.forEach(function(col) {
userCollections[col.name] = new Meteor.Collection(col.name);
Meteor.publish(col.name, function(){
return Mongo.Collection.get(col.name).find({});
});
console.log(userCollections[col.name]);
});
But in my client Folder my array is empty.
console.log(userCollections);
Why?
The Problem is:
userCollections = [];
userCollections["0"] = "0_test";
Collectionlist = CustomCollections.find({});
Collectionlist.forEach(function(col) {
userCollections["1"] = "1_test";
console.log(userCollections); //----> array -> "1":"1_test"
});
in my CollectionCursor-forEach and in my server folder the array is defined
console.log(userCollections); //----> array -> "0":"0_test"
but outside my forEach and in the client folder the array is undefined... There is a scope problem?