1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-09-21 03:09:15 -04:00
shimapan/app/util/upload/stats.js

13 lines
455 B
JavaScript

const ModelPath = '../../models/';
const User = require(ModelPath + 'User.js');
const Key = require(ModelPath + 'Key.js');
const updateStats = req =>
Promise.all([
User.updateOne({username: req.username}, {$inc: {uploadCount: 1, uploadSize: req.file.size}}),
req.key
? Key.updateOne({key: req.key}, {$inc: {uploadCount: 1, uploadSize: req.file.size}})
: Promise.resolve()
]);
module.exports = updateStats;