/** ----------------------- MongoDB Connection ------------------------
-
Create account
-
Create an user with password
-
Whitelist IP address
-
database > connect > driver > Node > show all code
-
Change the password in the uri
-------------------- Server side steps ---------------------
-
Create --- post
-
app.post('/users'/ async (req, res) =>{})
-
Make the function async to use await inside it
-
Make sure you use the express.json() middleware
-
access data from the body: const user = req.body
-
const result = wait userCollection.insertOne(user);
-
res.send(result)
----------------- Client Side -----------------
-
- create fetch
-
- add second parameter as an object
-
- provide method: 'POST'
-
- add headers :{'content-type':'application/json'}
-
-
add body: JSON.Stringify(user)
------------- Read MANY -------------
-
-
Create a cursor = userCollection.find()
-
const result = await cursor.toArray()
---------- DELETE ----------
-
create app.delete('/users/:id', async(req, res)=>{})
-
specify unique ObjectId to delete the right user
-
const query = {_id: new ObjectId(id)}
-
const result = await userCollection.deleteOne(query);
------------ Client ------------
-
Create dynamic url with id
-
make sure to mention the DELETE method
****/