I am writing a MERN app and am trying to get all the collection names in my MongoDB database using the db.getCollectionInfos method. However, I'm getting the following error:
Error: db.getCollectionInfos is not a function
Here is my code. The database is connected, as it is connected and returns document data with other routes I have in my app.
Can someone help me figure out what I'm doing wrong?
mongoose.connect(process.env.DATABASE, { useNewUrlParser: true });
const db = mongoose.connection;
app.post("/fetchdatabasecollections", (req, res) => {
let regex = /someRegEx/g;
let collections = db.getCollectionInfos({ name: { $regex: regex } });
})