Inderdaad, mongoose.connection.db.collectionNames
werd geschrapt ten gunste van 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();
});
});