Tatsächlich mongoose.connection.db.collectionNames
wurde zugunsten von mongoose.connection.db.listCollections
fallen gelassen .
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();
});
});