Created
June 15, 2020 13:41
-
-
Save NALAWALAMURTUZA/ac3009c805f0e5ca5ff14e38f613b866 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
import * as schedule from "node-schedule"; | |
import testModel from "../schema/test.model"; | |
class job { | |
constructor() { | |
} | |
//Shop code refresh at 12:00 AM | |
public shopRefresh() { | |
var rule = new schedule.RecurrenceRule(); | |
rule.dayOfWeek = [0, new schedule.Range(0, 6)]; | |
rule.hour = 18; | |
rule.minute = 0; | |
schedule.scheduleJob(rule, async function () { | |
const code = Math.floor(1000 + Math.random() * 9000); | |
const set = { | |
shopcode: code | |
} | |
await testModel.updateOne({_id: 1}, {$set: set}); | |
}); | |
} | |
} | |
export default new job(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment