Update database/database.js
Browse files- database/database.js +19 -1
database/database.js
CHANGED
@@ -56,6 +56,24 @@ class Database {
|
|
56 |
}
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
async AddIpisBlocked(ip) {
|
60 |
try {
|
61 |
const collection = this.collection();
|
@@ -65,7 +83,7 @@ class Database {
|
|
65 |
const result = await collection.updateOne(filter, update, { upsert: true });
|
66 |
|
67 |
if (result.upsertedCount > 0) {
|
68 |
-
console.log("Inserted
|
69 |
} else {
|
70 |
console.log("Updated an existing IP address:", ip);
|
71 |
}
|
|
|
56 |
}
|
57 |
}
|
58 |
|
59 |
+
async UnblockedIp(ip) {
|
60 |
+
try {
|
61 |
+
const collection = this.collection();
|
62 |
+
const filter = { ip: ip };
|
63 |
+
const update = { $set: { blocked: false } };
|
64 |
+
|
65 |
+
const result = await collection.updateOne(filter, update, { upsert: true });
|
66 |
+
|
67 |
+
if (result.upsertedCount > 0) {
|
68 |
+
console.log("IP address unblocked:", ip);
|
69 |
+
} else {
|
70 |
+
console.log("Updated an existing IP address:", ip);
|
71 |
+
}
|
72 |
+
} catch (error) {
|
73 |
+
console.error("Error updating IP address:", error.message);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
async AddIpisBlocked(ip) {
|
78 |
try {
|
79 |
const collection = this.collection();
|
|
|
83 |
const result = await collection.updateOne(filter, update, { upsert: true });
|
84 |
|
85 |
if (result.upsertedCount > 0) {
|
86 |
+
console.log("Inserted IP address blocked:", ip);
|
87 |
} else {
|
88 |
console.log("Updated an existing IP address:", ip);
|
89 |
}
|