diff --git a/README.md b/README.md index 932fff4..43af5e9 100644 --- a/README.md +++ b/README.md @@ -1 +1,28 @@ -# docker-testapp \ No newline at end of file +# Docker-testapp + +#### Info: + +In this app, we are using `MongoDB` for Database, but we haven't set it up. + +We are going to set it using `Docker`. For that we gonna need two images : + 1. mongo + 2. mongo-express ( a user interface for our mongo database ) + +***Note: We are NOT seting it up in our system. We are setting it in Docker.** * + +***Also, we want both of our containers to interact with each other without any `port` or `limitation`. For which, we are going to use `Docker Network`. + `Docker Network` is like an `isolated network area` & Containers inside a specific docker network can interact with each other without any limitations. + +--- + +-> For `mongo` container: + +Go to : Docker_testapp\References\images\1770547027322.png + +-> For `mongo-express` container: + +Go to : Docker_testapp\References\images\1770548213468.png + +Note : In the `MONGODB_URL` environment variable, that `mongo` after `@` is the name of our `mongo image's container`. + +--- diff --git a/References/images/1770547027322.png b/References/images/1770547027322.png new file mode 100644 index 0000000..6b27ae1 Binary files /dev/null and b/References/images/1770547027322.png differ diff --git a/References/images/1770548213468.png b/References/images/1770548213468.png new file mode 100644 index 0000000..65b0e8f Binary files /dev/null and b/References/images/1770548213468.png differ diff --git a/server.js b/server.js index d869597..f773b6e 100644 --- a/server.js +++ b/server.js @@ -15,7 +15,7 @@ app.get("/getUsers", async (req, res) => { await client.connect(URL); console.log('Connected successfully to server'); - const db = client.db("apnacollege-db"); + const db = client.db("college-db"); const data = await db.collection('users').find({}).toArray(); client.close(); @@ -29,11 +29,12 @@ app.post("/addUser", async (req, res) => { await client.connect(URL); console.log('Connected successfully to server'); - const db = client.db("apnacollege-db"); + const db = client.db("college-db"); const data = await db.collection('users').insertOne(userObj); console.log(data); console.log("data inserted in DB"); client.close(); + res.send("User added successfully") });