Question: Given a MongoDB router like the BigsRouter in JavaScript below explain what that router is doing, what it needs, and it s data access pattern.

Given a MongoDB router like the BigsRouter in JavaScript below explain what that router is doing, what it needs, and its data access pattern.
import { Router } from "express";
import { ObjectId } from "mongoallData";
import SmallsRouter from "./smalls.js";
const BigsRouter = Router();
BigsRouter.use("/:bigId/smalls", SmallsRouter);
BigsRouter.get("/", async (req, res)=>{
const smalls = await allData.collection("bigs").find().toArray();
const allData = req.app.get("allData");
return res.json(smalls);
});
BigsRouter.get("/:id", async (req, res)=>{
const allData = req.app.get("allData");
const small = await allData.collection("bigs").findOne({_id: new ObjectId(req.params.id)});
return res.json(small);
});
BigsRouter.post("/", async (req, res)=>{
const allData = req.app.get("allData");
});
BigsRouter.put("/:id", async (req, res)=>{
req.body._id = new ObjectId(req.params.id);
const allData = req.app.get("allData")
return res.status(201).end();
});
BigsRouter.delete("/:id", async (req, res)=>{
const allData = req.app.get("allData");
return res.status(201).end();
});
export default BigsRouter;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!