-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-mongo.js
More file actions
55 lines (48 loc) · 1.64 KB
/
test-mongo.js
File metadata and controls
55 lines (48 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import mongoose from 'mongoose'
import { connectDB } from './db/db.js'
import { UserDevice, QuizResult, AlertLog, FraudDetection } from './db/models.js'
await connectDB()
console.log('\n=== Checking MongoDB Data ===\n')
// Check registered devices
const devices = await UserDevice.find()
console.log(`📱 Total Devices Registered: ${devices.length}`)
if (devices.length > 0) {
devices.slice(0, 3).forEach(d => {
console.log(` - Device: ${d.deviceId}`)
console.log(` Created: ${d.createdAt}`)
console.log(` Last Active: ${d.lastActive}`)
})
}
// Check quiz results
const quizResults = await QuizResult.find()
console.log(`\n📊 Total Quiz Results: ${quizResults.length}`)
if (quizResults.length > 0) {
quizResults.slice(0, 3).forEach(r => {
console.log(` - Device: ${r.deviceId}`)
console.log(` Quiz: ${r.quizId}`)
console.log(` Score: ${r.score}/${r.totalQuestions}`)
console.log(` Percentage: ${r.percentage}%`)
})
}
// Check alerts
const alerts = await AlertLog.find()
console.log(`\n📢 Total Alerts: ${alerts.length}`)
if (alerts.length > 0) {
alerts.slice(0, 3).forEach(a => {
console.log(` - Device: ${a.deviceId}`)
console.log(` Message: ${a.message}`)
console.log(` Type: ${a.type}`)
})
}
// Check frauds
const frauds = await FraudDetection.find()
console.log(`\n🚨 Total Fraud Detections: ${frauds.length}`)
if (frauds.length > 0) {
frauds.slice(0, 3).forEach(f => {
console.log(` - Device: ${f.deviceId}`)
console.log(` Type: ${f.fraudType}`)
console.log(` Severity: ${f.severity}`)
})
}
console.log('\n=== ✅ Data Summary Complete ===\n')
process.exit(0)