確かに、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();
});
});