DtubeAuthProxy/peroidicActions/pruneUnpaidAccounts.js

24 lines
501 B
JavaScript
Raw Normal View History

2021-05-29 22:11:38 +00:00
mongo = require("../mongoHelp.js")
config = require("../config.js")
javalon = require("javalon")
function pruneUnpaidAccounts(){
agg = [ {'$match': {
timeLimit: { $lt: Date.now()}
}},
{'$match': {
status: "Inactive"
}}]
mongo.aggregate(config.database, "users", agg).then(oldArr => {
oldArr.forEach(element => {
mongo.deleteOne(config.database, "users", {_id:element._id})
})
})
}
setInterval(pruneUnpaidAccounts, 3600000)