Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dynamic collections with node.js and monogjs

i try to find a way to use vars for mongojs collections. The data are dynamic and also the db.VAR.find(); must be dynamic. Is there a solution for that problem. I searched here and google, but there is nothing. I hope you can help me.

Example:

var var1 = "game12"; var var2 = "game34";

db.***var1***.find({name: x},function(err, datas) {
     if( err || !datas ) {
        console.log("Problem finding data :" + err);
     }else{
         datas.forEach( function(curData) {
            console.log(curData);
         });
     } });


db.***var2***.find({name: x},function(err, datas) {
     if( err || !datas ) {
        console.log("Problem finding data :" + err);
     }else{
         datas.forEach( function(curData) {
            console.log(curData);
         });
     } });
like image 639
Omar Al-Khailany Avatar asked Feb 22 '26 06:02

Omar Al-Khailany


1 Answers

db[var1].find(...

db[var2].find(...

like image 92
JohnnyHK Avatar answered Feb 24 '26 21:02

JohnnyHK