So I'm trying to create a global variable that copies the MongoDB database into a new array, so I keep server calls at a minimum.
It looks like this:
db = _.map(MyCollection.find().fetch()[0], function(item){return item});
I place this into my /lib/constants.js folder to make sure it loads before anything else in client. I place it inside client, it works.
Ultimately, the db as a global variable doesn't work. Not sure what I'm doing wrong. Also, if you would be kind to answer this question also: Can I do regular JS statements like loops inside the lib folder to make the result load before the client does?
Thanks!