vote.js
462 Bytes
/**
* 投票
* @author: leo
* @date: 23/06/2017
*/
const mysqlCli = global.yoho.utils.mysqlCli;
function getAll(req, res) {
mysqlCli.query('select * from vote')
.then(result => {
res.end(JSON.stringify(result));
});
}
function addOne(req, res) {
mysqlCli.insert(`insert vote (name) values ('${req.query.name}');`)
.then(insertId => {
res.end(insertId.toString());
});
}
module.exports = {
getAll,
addOne
};