POST end Point using Mongo DB


I need some help creating a POST end Point using Mongo DB . my Schema is defined as follows:

const Collection1 = { projectno:“String” projectname: “String”, };

const Collection2 = { activityname:“String”, projectname: [{ type: Schema.ObjectId, ref: “Collection” }], };

My Challenge is, creating the POST Api endpoint route to capture the projectname data stored in Collection1 model. This is my current Implementation which is giving me a 400 Bad request on Postman

… router.route("/createactivity").post((req, res) => { const project = Collection1.findById({ path: “collection1Id”, select: “projectname”, }); const activityname = req.body.activityname; const projectname = { project: { _id: project._id, name: }

const newActivity = new Activity({


Let me know if there’s a better way i can implement the API.