Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
# docker-testapp
# 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`.

---
Binary file added References/images/1770547027322.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added References/images/1770548213468.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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")
});


Expand Down