How do I use a dynamic variable as a Meteor/MongoDB collection name? -
so tried didn't work (on isserver) :
var tablename= ""; (...) if (silly_cond === 1){ tablename = "table1"; }else{ tablename = "table2"; } tablecol = new mongo.collection(tablename);
for reason can't work. seems accept
tablecol = new mongo.collection("table1");
the idea fetch tablename table id, , apply same js different tables (on different templates). doing wrong?
you need declare tablename
outside functions, otherwise can't seen.
var tablename = ""; if (silly_cond === 1){ tablename = "table1"; }else{ tablename = "table2"; } tablecol = new mongo.collection(tablename);
Comments
Post a Comment