forked from UKSOURCE/cms.hailearning.edu.vn
feat: implement comprehensive audit logging system
This commit is contained in:
29
scripts/create-audit-log.js
Normal file
29
scripts/create-audit-log.js
Normal file
@@ -0,0 +1,29 @@
|
||||
require("dotenv").config();
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
await mongoose.connect(process.env.MONGODB_URI);
|
||||
|
||||
console.log("Connected DB");
|
||||
|
||||
const collections = await mongoose.connection.db
|
||||
.listCollections({ name: "auditlogs" })
|
||||
.toArray();
|
||||
|
||||
if (collections.length > 0) {
|
||||
console.log("AuditLog collection already exists");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
await mongoose.connection.createCollection("auditlogs");
|
||||
console.log("AuditLog collection created");
|
||||
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user