Fail to connect Mongoose to Atlas

后端 未结 3 1336
抹茶落季
抹茶落季 2020-12-01 09:52

I\'m always connecting to the \"admin\" DB, which is a fixed bug.

Using Mongoose 5.0.6 MongoDb 3.6 and trying to connect to Atlas.

  1. My question, what dr
3条回答
  •  佛祖请我去吃肉
    2020-12-01 10:16

    Connection is established when you use this connection string for (MongoShell 3.6+) :

    var connDB = "mongodb+srv://:@cluster-fax0w.mongodb.net/test"
    

    However, you will not be able to read/write data without entering the DBName in the mongoose.connect().

    mongoose.connect(uri, { dbName:  })
      .then( () => {
        console.log('Connection to the Atlas Cluster is successful!')
      })
      .catch( (err) => console.error(err));
    

提交回复
热议问题