Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MongoParseError: URI malformed, cannot be parsed #47

Open
xc3256 opened this issue Aug 19, 2019 · 1 comment
Open

MongoParseError: URI malformed, cannot be parsed #47

xc3256 opened this issue Aug 19, 2019 · 1 comment

Comments

@xc3256
Copy link

xc3256 commented Aug 19, 2019

代码如下
const MongoClient = require('mongodb').MongoClient;
const uri = "mongodb+srv://username:[email protected]/test?retryWrites=true&w=majority";
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
const collection = client.db("test").collection("devices")
.then(db => console.log("DB Connected"))
.catch(err => console.log(error))
});

module.exports = {
mongodb: client
}

怀疑报错的原因是不是MongoDB 现在的url是mongodb+srv开头了,但是Mongolass并不支持新format????

@nswbmw
Copy link
Owner

nswbmw commented Aug 28, 2019

Mongolass封装的官方 mongodb 库建立连接,不太可能是 Mongolass内部的问题。你再查下~

https://github.com/mongolass/mongolass/blob/master/lib/index.js#L42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants