A while back I made a feature request that adds a way of scheduling code to be executed at a specific time. Some time later, Wix added jobs, which does essentially that.
Now, I also requested a way of creating jobs using code, an API. It would be something like the following example:
import wixJobs from 'wix-jobs';
wixJobs.insert( {
"functionLocation": "/utils/dbUtils.deleteExpired",
"description": "Delete the expired DB items",
"executionConfig": {
"time": "22:00",
"dayOfWeek": "Sunday"
}
} );
And also, a way of removing a job, like the following example:
import wixJobs from 'wix-jobs';
wixJobs.remove("Delete the expired DB items");
In the previous example I used the description of a job to remove it, there could be an id or we could just use the item index.
Thanks.