1//IMPORTS
2import express from "express";
3import mongoose from "mongoose";
4
5const app = express();
6
7//MIDDLEWARES
8app.use("/");
9
10//MIDDLEWARE TO TRANSFER DATA
11app.use(express.urlencoded({ extended: true }));
12app.use(express.json({ limit: "30mb", extended: true }));
13
14//CONSTANTS
15const CONNECTION_PORT = "YOUR_MONGODB_CONNECTION_LINK_HERE";
16const PORT = process.env.PORT || 5000;
17
18//CONNECTION WITH MONGOOSE DB AND LISTENING TO PORT
19mongoose
20 .connect(CONNECTION_PORT, {
21 useNewUrlParser: true,
22 useUnifiedTopology: true,
23 })
24 .then(() => {
25 app.listen(PORT, () => {
26 console.log(`Server Running on port ${PORT}`);
27 });
28 })
29 .catch((err) => {
30 console.log(err);
31 });
1var MongoClient = require('mongodb').MongoClient
2
3MongoClient.connect('mongodb://localhost:27017/animals', function (err, client) {
4 if (err) throw err
5
6 var db = client.db('animals')
7
8 db.collection('mammals').find().toArray(function (err, result) {
9 if (err) throw err
10
11 console.log(result)
12 })
13})
14
1var mysql = require('mysql')
2var connection = mysql.createConnection({
3 host: 'localhost',
4 user: 'dbuser',
5 password: 's3kreee7',
6 database: 'my_db'
7})
8
9connection.connect()
10
11connection.query('SELECT 1 + 1 AS solution', function (err, rows, fields) {
12 if (err) throw err
13
14 console.log('The solution is: ', rows[0].solution)
15})
16
17connection.end()
18
1app.post('/quotes', (req, res) => { console.log(req.body) })You should be able to get an object similar to the following in your command line:{name: 'pdp',quotes: 'pdp psr pdp'}