mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 09:36:08 +08:00
17 lines
437 B
JavaScript
17 lines
437 B
JavaScript
const db = require('../service/db.js');
|
|
|
|
const coll = db.collection('blacklist');
|
|
|
|
async function add(ip) {
|
|
const expireAt = new Date(new Date().getTime() + 365 * 24 * 60 * 60 * 1000);
|
|
return coll.findOneAndUpdate({ _id: ip }, { $set: { expireAt } }, { upsert: true });
|
|
}
|
|
function get(ip) {
|
|
return coll.findOne({ _id: ip });
|
|
}
|
|
function del(ip) {
|
|
return coll.deleteOne({ _id: ip });
|
|
}
|
|
|
|
module.exports = { add, get, del };
|