RRo*_*Rob 6 heroku mongodb node.js
尝试从 Heroku 上托管的 NodeJS 应用程序连接到 MongoDB 云上的 mongodb。使用 mongodb ^3.2.3 和 MongoDBClient,在我的机器上本地运行很好,但在部署到 Heroku 后,得到上面的错误:“MongoError: MongoClient must be connected before call MongoClient.prototype.db”
const uri = "mongodb+srv://myuser:mypass@mongodbcluster/test?retryWrites=true";
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
    db = client.db("collection"); // <-- this is where it fails
...
Run Code Online (Sandbox Code Playgroud)
    |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           9923 次  |  
        
|   最近记录:  |