i am trying the following code to create a new DB but it dosen't show up in my MongoDB localhost connection. I used the callback function and it returned no error.
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/personDB", { useUnifiedTopology: true, useNewUrlParser: true });
Please add error in you question. I think this is enough. Check whether mongodb is running fine.
Try this
const mongoose = require('mongoose')
mongoose.connect(process.env.DATABASE, {
useUnifiedTopology: true,
useNewUrlParser: true
})
mongoose.connection.once('open', () => {
console.log("Connected")
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.