Warning on Connecting to MongoDB with a Node server

后端 未结 5 1447
有刺的猬
有刺的猬 2021-02-01 03:16

Connecting with MongoDB native driver

I wrote following code to connect mongodb through native driver which has been install with npm install mongodb --save

5条回答
  •  长发绾君心
    2021-02-01 03:33

    Check your mongo version

     mongo --version
    

    If you are using version >= 3.1.0 change you mongo connection file to ->

     MongoClient.connect("mongodb://localhost:27017/YourDB", {
       useNewUrlParser: true,
       useUnifiedTopology: true
     })
    

    For details about the useUnifiedTopology option added in 3.2.1, see https://github.com/mongodb/node-mongodb-native/releases/tag/v3.2.1

提交回复
热议问题