Skip to content

Instantly share code, notes, and snippets.

@Rowadz
Last active April 7, 2019 19:48
Show Gist options
  • Select an option

  • Save Rowadz/7cafab33946f4e8807ec6db3781b97e1 to your computer and use it in GitHub Desktop.

Select an option

Save Rowadz/7cafab33946f4e8807ec6db3781b97e1 to your computer and use it in GitHub Desktop.
module.exports = function (app) {
return async (req, res, next) => {
const {
files
} = req;
const fileRes = [];
const seq = app.get('sequelizeClient');
const { media } = seq.models;
for (const file of files) {
fileRes.push(
await media.create({
path: file.path
})
// OR
// await app.service('media').create({
// path: file.path
// })
);
}
res.json(fileRes);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment