无法将猫鼬连接到 Atlas [英] Fail to connect Mongoose to Atlas
本文介绍了无法将猫鼬连接到 Atlas的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我总是连接到admin"数据库,这是一个修复的错误.
I'm always connecting to the "admin" DB, which is a fixed bug.
使用 Mongoose 5.0.6 MongoDb 3.6 并尝试连接到 Atlas.
Using Mongoose 5.0.6 MongoDb 3.6 and trying to connect to Atlas.
- 我的问题是,Mongoose 5.0.6 依赖什么驱动程序?
- 我如何才能知道 Mongoose 何时会修复该问题?
- 换个方向,有没有办法与 MongoDB 连接,然后将此连接用于猫鼬?
干杯
推荐答案
基本上你应该尝试用你的 url 链接连接,并在 mongoose 连接方法上指定数据库名称所以如果你的集群链接是:
Basically you should try connecting with your url link, and specify the DB name on the mongoose connect method so if your cluster link is:
mongodb+srv://userName:Passwrod@clustor.mongodb.net/
您的数据库名称是:
testDB
那么你应该调用mongoose.connect方法如下:
then you should call the mongoose.connect method as follows:
mongoose.connect('mongodb+srv://userName:Passwrod@cluster.mongodb.net/', {dbName: 'testDB'});
这篇关于无法将猫鼬连接到 Atlas的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文