节点计划,删除功能删除用户而不是目标数据

时间:2020-04-26 19:13:52

标签: express node-schedule

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删除数据。而是删除整个用户。

0 个答案:

没有答案