0
我試圖連接我已經構建到MongoHQ數據庫的應用程序。連接到節點上的MongoHQ,錯誤
這是代碼:
mongo = require('mongodb')
Server = mongo.Server
Db = mongo.Db
BSON = mongo.BSONPure;
con = null;
server = new Server('staff.mongohq.com', 'THE_PORT', {auto_reconnect: true});
DBCon = new Db('THE_DB', server, {safe: false});
DBCon.authenticate('test_user', 'test_pass', function() {});
DBCon.open(function(err, db) { if(!err) { con = db; } });
我有數據庫和MongoHQ創建的用戶。當我從命令行連接時,一切正常。
但是當我運行我的應用程序,我得到這個錯誤:
return this.connectionPool.getAllConnections();
TypeError: Cannot call method 'getAllConnections' of undefined
它無法連接到數據庫。 但是,當我沒有身份驗證連接到我的本地數據庫時,它正常工作。
那麼,什麼是錯誤,我應該如何解決它?
謝謝! :D