-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.js
50 lines (49 loc) · 1.39 KB
/
db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const mongoose = require("mongoose");
const dotenv = require("dotenv");
dotenv.config();
// async function connectdb() {
// try {
// await mongoose.connect("mongodb://127.0.0.1:27017/ecommerce", {
// useNewUrlParser: true,
// });
// console.log("Connected to MongoDB");
// } catch (error) {
// console.error("Could not connect to MongoDB", error);
// throw error;
// }
// }
// async function connectdb() {
// try {
// await mongoose.connect(process.env.MONGO_URL, {
// useNewUrlParser: true,
// useUnifiedTopology: true,
// dbName: "eshop-database",
// });
// console.log("Connected to MongoDB");
// } catch (error) {
// console.error("Could not connect to MongoDB", error);
// throw error;
// }
// }
// // })
// // .then(() => {
// // console.log("Database connection is ready");
// // })
// // .catch(() => {
// // console.log(err);
// // });
// // app.listen(3000, () => {
// // console.log("Server is Runinning in http://localhost:3000");
// // });
mongoose
.connect(process.env.MONGO_URL)
// "mongodb+srv://alinour:[email protected]/ecommerce?retryWrites=true&w=majority"
// )
.then(() => {
console.log("Database connection is ready");
})
.catch(() => {
console.log("error");
});
// module.exports = { connectdb };
// "process.env.MONGO_URL"