I’m defining a local collection like this: LC = new Mongo.Collection(null);
I then populate the local collection using LC.insert(...);, which works fine (I check the contents and the count (15 documents) and it is as expected).
However, when I route (using iron router) to a different page, then press the back button, the local collection is emptied. I see that the LC.find().count() returns 0 when I press the back button.
Is there a reason why the local collection doesn’t persist across browser navigation?
@Sanjo I have my router.js which contains all of my routes only;
and another JS file myProgram.js which contains the if(Meteor.isClient) and if(Meteor.isServer blocks), and I define LC = new Mongo.Collection(null) outside of both if(Meteor.isClient) and if(Meteor.isServer) blocks.
Is that the correct way?
LC = new Mongo.Collection(null);
if(Meteor.isClient){
...
}
if(Meteor.isServer){
...
}
@Sanjo: I placed a debugger right above the LC = new Mongo.Collection(null) line, and it only executes once when I start up the localhost. That line doesn’t seem to execute again so I don’t know what’s going on.
I should mention that I never removed meteor autopublish so I’m assuming that isn’t the problem…