【发布时间】:2020-07-27 14:17:39
【问题描述】:
我需要你的帮助来将我的 mongodb 数据库连接到集群图集,我配置了我的 IP、用户名和密码。我正在使用heroku进行部署。感谢帮助!但我不能,见下文:
表达:“^4.17.1”, 快速会话:“^1.17.0”, 猫鼬:“^5.8.3”,
const mongoose = require('mongoose');
const db = { mongoURI: 'mongodb+srv://username:password@blog-prod-upfzz.mongodb.net/test?retryWrites=true&w=majority' }
mongoose.Promise = global.Promise;
mongoose.connect(db.mongoURI, {
useUnifiedTopology: true,
useNewUrlParser: true
}).then(() => {
console.log('Successfully');
}).catch((err) => {
console.log('Error: ' + err);
});
【问题讨论】:
标签: javascript node.js mongodb express mongoose