当前位置: 代码迷 >> 综合 >> Mongoose - 连接
  详细解决方案

Mongoose - 连接

热度:60   发布时间:2024-01-15 11:33:54.0

安装mongoose

npm install mongoose

连接本地数据库mongoose-test

var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/mongoose-test');var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function() {console.info('we are connected!');
});