1
0
mirror of https://github.com/Foltik/Shimapan synced 2024-11-15 17:18:05 -05:00
shimapan/app/util/upload/stats.js

13 lines
455 B
JavaScript
Raw Normal View History

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;