unpkg/modules/utils/incrementCounter.js

16 lines
319 B
JavaScript

const db = require("./data");
function incrementCounter(counter, key, by = 1) {
return new Promise((resolve, reject) => {
db.hincrby(counter, key, by, (error, value) => {
if (error) {
reject(error);
} else {
resolve(value);
}
});
});
}
module.exports = incrementCounter;