-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongodb.txt
36 lines (27 loc) · 908 Bytes
/
mongodb.txt
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
mongosh "mongodb+srv://cluster0.oukkq7r.mongodb.net/" --apiVersion 1 --username sk4118251
import mongoose from "mongoose";
import { DB_NAME } from "./constants.js";
import express from "express";
import dotenv from "dotenv";
dotenv.config({
path: 'env'
})
const app = express();
;(async ()=>{
try {
await mongoose.connect(`${process.env.MONGODB_URI}/${DB_NAME}`);
app.on("error", (error)=>{
console.log("ERROR:", error);
throw error
})
// console log the data present in the users document of test collection
const admins = await mongoose.connection.db.collection('admins').find({}).toArray();
console.log(admins);
app.listen(process.env.PORT, ()=>{
console.log("APP IS LISTENING ON PORT: ", process.env.PORT);
} )
} catch (error) {
console.error("ERROR", error);
throw error
}
})()