構築したアプリを 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