Format stuff
This commit is contained in:
@@ -4,24 +4,25 @@ const connectDB = async () => {
|
|||||||
const conn = await mongoose.connect('mongodb://mongodb:27017/tombola', {
|
const conn = await mongoose.connect('mongodb://mongodb:27017/tombola', {
|
||||||
});
|
});
|
||||||
console.log(`MongoDB Connected: ${conn.connection.host}:${conn.connection.port}`);
|
console.log(`MongoDB Connected: ${conn.connection.host}:${conn.connection.port}`);
|
||||||
// Get and log database stats
|
// Get and log database stats
|
||||||
const dbStats = await conn.connection.db.stats();
|
const dbStats = await conn.connection.db.stats();
|
||||||
console.log("Database Stats:", dbStats);
|
console.log("Database Stats:", dbStats);
|
||||||
|
|
||||||
// Get and log all collections in the database
|
// Get and log all collections in the database
|
||||||
const collections = await conn.connection.db.collections();
|
const collections = await conn.connection.db.collections();
|
||||||
console.log("Collections:");
|
if (collections.length > 0) {
|
||||||
collections.forEach(collection => {
|
console.log("Collections:");
|
||||||
console.log(collection.collectionName);
|
collections.forEach(collection => {
|
||||||
});
|
console.log(collection.collectionName);
|
||||||
|
});
|
||||||
|
// Get and log the indexes of a specific collection (optional)
|
||||||
|
const collectionName = "collectionname"; // Replace with your collection name
|
||||||
|
const indexes = await conn.connection.db.collection(collectionName).indexes();
|
||||||
|
console.log(`Indexes in ${collectionName}:`);
|
||||||
|
console.log(indexes);
|
||||||
|
}
|
||||||
|
|
||||||
// Get and log the indexes of a specific collection (optional)
|
console.log("Finish Database Stats.");
|
||||||
//const collectionName = "tombola"; // Replace with your collection name
|
|
||||||
//const indexes = await conn.connection.db.collection(collectionName).indexes();
|
|
||||||
//console.log(`Indexes in ${collectionName}:`);
|
|
||||||
//console.log(indexes);
|
|
||||||
|
|
||||||
console.log("Finish Database Stats.");
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error.message);
|
console.error(error.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user