दरअसल, mongoose.connection.db.collectionNames
mongoose.connection.db.listCollections
. के पक्ष में छोड़ दिया गया था ।
const mongoose = require('mongoose');
const connection = mongoose.connect('mongodb://localhost:27017');
connection.on('open', function () {
connection.db.listCollections().toArray(function (err, names) {
if (err) {
console.log(err);
} else {
console.log(names);
}
mongoose.connection.close();
});
});