私はcompoundjsで作業しており、jugglingdbのmongodbアダプターを使用しています。次のようにして、コントローラーでネイティブの mongodb クライアントを取得して再利用しています。
var db = compound.orm._schemas[0].client;
.collection(name)
などのmongodb がサポートする関数を使用できるため、これはうまく機能します.find()
。ただし、compoundjs のイニシャライザを作成すると、.client
空ですが、そうで_schemas[0]
はないようです。例えば:
module.exports = function (compound) {
var db = compound.orm._schemas[0].client; // _schemas[0] isn't empty as .client was reached.
db.collection('collection'); // Throws: TypeError: Cannot call method 'collection' of undefined
};
自分で接続を再作成せずに、ネイティブの mongodb クライアントを jugglingdb アダプターから取得するにはどうすればよいですか?