-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnmongodb.js
More file actions
54 lines (43 loc) · 1.67 KB
/
nmongodb.js
File metadata and controls
54 lines (43 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const express = require("express");
const _book_connection = require("./mongodb/edudb/book_connection");
const _cloth_connection_ = require("./mongodb/shopdb/cloth_connection");
const _fish_connection_ = require("./mongodb/shopdb/fish_connection");
const _food_connection = require("./mongodb/shopdb/food_connection");
const laptop_connection_ = require("./mongodb/shopdb/laptop_connection");
const app = express();
app.use(express.json());
const port = 9000;
app.get("/", (req, res)=> {
res.send("The app is running");
})
app.listen(port, ()=> {
console.log(`The app is running on port number ${port}, visit http://localhost:${port}`);
})
// **************************************************** post section **************************************************************
app.post("/post", async (req, res) => {
const book_connection_ = await _book_connection();
const data = await book_connection_.insert(req.body);
res.send(data);
})
app.post("/food_data", async(req, res)=> {
const foo = await _food_connection();
const data = await foo.insert(req.body);
res.send(data);
// console.log(req.body);
})
app.post("/laptop_data", async(req, res) => {
const laptop_connection = await laptop_connection_();
const data =laptop_connection.insert(req.body);
res.send(data);
})
app.post("/fish_data", async(req, res)=> {
const _fish_connection = await _fish_connection_();
const data = _fish_connection.insert(req.body);
res.send(data);
console.log(req.body);
})
app.post("/cloth_data", async(req, res)=> {
const _cloth_connection = await _cloth_connection_();
const data = _cloth_connection.insert(req.body);
res.send(data);
})