schedule.scheduleJob('0 0 4 * * *',
function (fireDate) {
console.log(`fireDate: ${fireDate}`);
console.log(`now: ${new Date()}`);
resetUserData()
.then(result => {
console.log(`data removed at ${new Date()}`);
console.log('result:\n', result);
})
.catch(reason => {
console.error(`removing data failed at ${new Date()}`);
console.error(`reason: ${reason}`);
});
});
function resetUserData(){
return db('users')
.select('water', 'exercise', 'sleep', 'breaks', 'daily_points')
.del()
}
重置功能数据应基于.select删除数据。而是删除整个用户。