forked from smitgoyani123/Dayflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_db.js
More file actions
36 lines (30 loc) · 1.13 KB
/
debug_db.js
File metadata and controls
36 lines (30 loc) · 1.13 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
import mongoose from 'mongoose';
import dotenv from 'dotenv';
import Employee from './backend/models/Employee.js';
dotenv.config({ path: './backend/.env' });
const connectDB = async () => {
try {
const conn = await mongoose.connect(process.env.MONGO_URI);
console.log(`MongoDB Connected: ${conn.connection.host}`);
// Find the most recent employee
const emp = await Employee.findOne().sort({ createdAt: -1 });
if (emp) {
console.log('Most Recent Employee Found:');
console.log('Name:', emp.firstName, emp.lastName);
console.log('Has companyLogo?', !!emp.companyLogo);
if (emp.companyLogo) {
console.log('Logo Length:', emp.companyLogo.length);
console.log('Logo Start:', emp.companyLogo.substring(0, 50));
} else {
console.log('Logo Field is Empty or Missing');
}
} else {
console.log('No employees found.');
}
process.exit();
} catch (error) {
console.error(`Error: ${error.message}`);
process.exit(1);
}
};
connectDB();