javascript - TypeError: Cannot read property 'find' of undefined -


i doing piece of code:

 var mongoclient = require('mongodb').mongoclient;      // connect db     mongoclient.connect("mongodb://${server}:27017/${db}", function(err, db) {       if(!err) {         console.log("successfully connected database");       }else{         console.log("error on connecting... aborting , exiting");         return console.dir(err);         throw err;        }         db.authenticate('username', 'password', function(err, res) {         var startid = 7882;         var usercount = 100;         var num = 190;         var basegeologorig = db.geologs.find({user_id:279, created_at:{$gte:new isodate("2015-01-31"), $lte:new isodate("2015-02-02")}}).limit(1227);         var basegeolog = [];       // callback         console.log("reached here...!");          });     }); 

after connected database , tried operations got following error:

/usr/lib/node_modules/mongodb/lib/utils.js:97     process.nexttick(function() { throw err; });                                         ^ typeerror: cannot read property 'find' of undefined     @ /home/scripts/mongoscript.js:16:36     @ handlecallback (/usr/lib/node_modules/mongodb/lib/utils.js:95:12)     @ /usr/lib/node_modules/mongodb/lib/db.js:1320:22     @ /usr/lib/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/replset.js:565:28     @ /usr/lib/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:1013:20     @ /usr/lib/node_modules/mongodb/node_modules/mongodb-core/lib/auth/mongocr.js:118:17     @ /usr/lib/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:754:46     @ callbacks.emit (/usr/lib/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:95:3)     @ null.messagehandler (/usr/lib/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:243:23)     @ socket.<anonymous> (/usr/lib/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:262:22) 


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -