const mongoose = require('mongoose'); const path = require('path'); require('dotenv').config({ path: path.join(__dirname, '../.env.local') }); const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017/backone_dpi'; async function run() { console.log('Connecting to:', MONGODB_URI); try { await mongoose.connect(MONGODB_URI, { serverSelectionTimeoutMS: 5000, }); console.log('Connected!'); const db = mongoose.connection.db; const collections = await db.listCollections().toArray(); console.log('Collections:', collections.map(c => c.name)); // Try raw query on users collection const users = await db.collection('users').find({}).toArray(); console.log('Raw users in DB:', users.map(u => ({ username: u.username, role: u.role, site_uuid: u.site_uuid, agent_uuid: u.agent_uuid, created_by: u.created_by }))); await mongoose.disconnect(); } catch (err) { console.error('Error:', err); } } run();