I want to reset/delete all entries from all collections of my database, after a certain period of time in MongoDB for NodeJs. What can be the possible methods to do it?
MongoClient.connect(url, { useNewUrlParser: true }, function(err,
db) {
if (err) throw err;
var dbo = db.db("process.env.DB_NAME");
var myquery = {};
dbo.collection("TableStatus").deleteMany(myquery, function(err,
obj) {
if (err) throw err;
console.log(obj.result.n + " document(s) deleted");
});
});
I have included this code in a function. So maybe there is a way to call this function after a certain period of time?