0% found this document useful (0 votes)
20 views3 pages

Role of MongoDB, and AngularJS in Full Stack

role of AngularJS in full stack

Uploaded by

reneeshcz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

Role of MongoDB, and AngularJS in Full Stack

role of AngularJS in full stack

Uploaded by

reneeshcz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

When working with MERN stack, developers create implement View

layer using Angular, Express and Node are used to implement


application layer of website then MongoDB is used to implement
database layer.
Communication between these components happens via HTTP
requests and responses. Angular, on the client-side, sends requests to
the Express.js server, which interacts with MongoDB to fetch or modify
data. The server then sends required data back to Angular for
rendering

In the MEAN stack—which stands for MongoDB, Express.js, AngularJS,


and Node.js
MongoDB serves as the NoSQL database, storing application data in
flexible, JSON-like documents.
Express.js acts as a middleware between AngularJS and MongoDB.
MongoDB stores data in collections (similar to tables) and documents
(similar to rows).
Once MongoDB returns the data, Express sends it as a JSON response.
AngularJS receives the data and updates the UI dynamically.
1. AngularJS Initiates the Request
$http.post('/api/patients', patientData);
2. Express.js Routes the Request
app.post('/api/patients', (req, res) => {
const newPatient = new Patient(req.body);
newPatient.save()
.then(() => res.status(201).send('Patient added'))
.catch(err => res.status(500).send(err));
});
3. Node.js Executes Server Logic
• Node.js runs the Express server and handles asynchronous
operations.
4. MongoDB Stores and Retrieves Data
const Patient = mongoose.model('Patient', {
name: String,
age: Number,
diagnosis: String
});
Data Returned to AngularJS
• Once MongoDB processes the query, Express sends the result
back as a JSON response.
[
{ "name": "Asha", "age": 45, "diagnosis": "Hypertension" },
{ "name": "Ravi", "age": 60, "diagnosis": "Diabetes" }
]

You might also like