-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-db.js
More file actions
50 lines (43 loc) · 1.85 KB
/
Copy pathdebug-db.js
File metadata and controls
50 lines (43 loc) · 1.85 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
const mongoose = require('mongoose');
const dns = require('dns');
dns.setServers(['8.8.8.8', '8.8.4.4']);
const User = require('./backend/models/User');
const InternshipApplication = require('./backend/models/InternshipApplication');
const path = require('path');
require('dotenv').config({ path: path.join(__dirname, 'backend', '.env') });
async function debug() {
const MONGO_URI = process.env.MONGO_URI || 'mongodb://localhost:27017/lnmiit_sti';
console.log('Connecting to:', MONGO_URI.split('@').pop()); // Hide credentials
try {
await mongoose.connect(MONGO_URI);
console.log('Connected to DB');
const user = await User.findOne({ name: /Satvik/i });
if (!user) {
console.log('User Satvik not found');
console.log('Finding all students to see names:');
const allStudents = await User.find({ role: 'student' }).limit(5);
allStudents.forEach(s => console.log(' -', s.name, 'CGPA:', s.cgpa));
} else {
console.log('User Details:');
console.log(' - Name:', user.name);
console.log(' - Email:', user.email);
console.log(' - CGPA (raw):', user.cgpa);
console.log(' - CGPA (typeof):', typeof user.cgpa);
}
const app = await InternshipApplication.findOne({ student: user?._id }).sort({ createdAt: -1 });
if (app) {
console.log('Latest Application Details:');
console.log(' - Company:', app.companyName);
console.log(' - CGPA (raw):', app.cgpa);
console.log(' - CGPA (typeof):', typeof app.cgpa);
} else {
console.log('No application found for user');
}
} catch (err) {
console.error('Debug script error:', err);
} finally {
await mongoose.disconnect();
console.log('Disconnected');
}
}
debug();