Mongoose expose the mongodb.DB instance
via mongoose.connection.db
, so you can use directly the
mongodb native driver
For example, if you want to print out all the data stored in a collection without
defining schema
let mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/testDB').then(() => {
const db = mongoose.connection.db;
db.collection('collection-name').find().toArray((err, result) => {
console.log(result)
});
}).catch(err => console.log(err.message))
See mongodb native driver documentation
for more examples