Node.js: Upload large file to MongoDB AND data from text inputs on the same page to different collections Node.js: Upload large file to MongoDB AND data from text inputs on the same page to different collections mongoose mongoose

Node.js: Upload large file to MongoDB AND data from text inputs on the same page to different collections


Actually when using multer, the text-fields from your form should still be populated under req.body.<field-name>, so you should be able to just use your initial code for inserting the tour-data:

app.post("/office/add-score", upload.single("file"), (req, res) => {  const addedTour = new Tour({    tour: {      tourHeading: req.body.tourHeading,      tourDescription: req.body.tourDescription,    },    program: {      tourProgram: req.body.tourProgram,      tourProgramDescription: req.body.tourProgramDescription,    }  });  addedTour.save(...)});