I have a requirement where i only need to keep all the data that are not older than 7 days. All the data older that should be auto deleted from the database. I want to do this in NodeJs in ExpressJs server.
I have read that i can use setInterval() function for this.
function intervalFunc() {
//send DELETE request to delete rows older than 7 days.
}
setInterval(intervalFunc,604800000); //interval of 7 days
I want to know how do i write the Delete request to delete only those records that are older than 7 days. And, if there's a better a way to do this??