Thanks (again) for the package.
Really easy to use, loving it.
I have managed to populate the metadata field when uploading (I've changed some variable names, sorry about any funky naming):
const upload = new Upload({
filename: req.file.originalname,
metadata: {
tmpName: req.file.filename,
version: 1
},
});
uploaded = await upload.upload(fileStream);
This upload gets associated to a parent document that contains some more advanced metadata specific to how the file is used.
I would now like to add the id of the parent doc to the upload metadata. Something like this:
Parent.create(req.body)
.then(async (data) => {
uploaded.metadata.template_id = data._id;
// also tried await
uploaded.save().then(updated => {
return res.status(201).json(data);
})
})
.catch((err) => {...});
Everything I've tried so far looks like it should work, I.e returning the data has the expected values in the metadata. but it doesn't actually make it to the database.
Have you come across this issue before and if so how did you tackle it?