我试图断开我与var conn = mongoose.createConnection('mongodb://'+ ip + ':' + port, options);
conn.on('connected', function () {
new Admin(conn.db).listDatabases(function(err, result) {
// process data ...
conn.disconnect();
res.sendStatus(200);
});
});
连接的数据库:
/var/node_modules/mongoose/node_modules/mongodb/lib/utils.js:123
process.nextTick(function() { throw err; });
^
TypeError: Object [object Object] has no method 'disconnect'
at /var/app.js:47:25
at handleCallback (/var/node_modules/mongoose/node_modules/mongodb/lib/utils.js:120:56)
at /var/node_modules/mongoose/node_modules/mongodb/lib/db.js:994:22
at /var/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:469:18
at process._tickCallback (node.js:458:13)
但是我收到了错误
conn.db.disconnect()
我还尝试了<?= $form->field($model, 'parent_id')->dropDownList($categories, ['class' => 'select']) ?>
<?= $form->field($model, "[{$lang['id']}]anchors",['template' => $template])->textarea(['class' => 'form-control editor']);?>
,它返回了相同的错误。
答案 0 :(得分:1)
没有conn.disconnect()
,但有conn.close()
。
是mongoose.disconnect()
,但我认为不会与mongoose.createConnection()
建立密切联系。