I have to store large amount of data in mongoose collection and it is getting really big and hard to handle. I want to save PDF files in somewhere and link it in the mongoose collection, I am not really sure for the best solution. Since most links are about direct file upload where as I am using pdfmake library which then stores to collection.
Here is my current model
annual.js
customerReport: {
createdBy: String,
creationDate: String,
hour: Number,
waitingHour: Number,
ccEmails: Array,
sendToEmail: String,
pdf: Schema.Types.Mixed,
customerNotes: String
},
this pdf has whole pdf content inside.
and in my route when I save and store the data finally
router.post('/stage/complete', (req, res, next) => {
var completed = new AnnualStage({
specs: req.body.specs,
contactDetails: req.body.contactDetails,
CalculationData: req.body.calculationData,
customersData req.body.customersData
customerReport: req.body.customerReport,
});
completed
.save()
.then(result => {
res.status(200).json({
result: result
});
})
.catch(err => {
res.status(500).json({
message: err.message
});
});
});
All the front end is done by Angular 6 and generates all data and pdf and save it to mongo collection
you can see inside I have added GridFs inside the route but where it will store the files and how it will link back to DB?