MongoDB backend - TypeError: <class>.injectDB is not a function

import app from "./server.js"
import mongodb from "mongodb"
import dotenv from "dotenv"
import FBrainUsersDAOs from "./dao/fBrainUsersDAO.js"
dotenv.config()
const MongoClient = mongodb.MongoClient;

const port = process.env.PORT || 8000

MongoClient.connect(process.env.FB_USERS_DB_URI, {
    maxPoolSize: 50,
    wtimeoutMS: 2500,
    useNewUrlParser: true,
})
  .catch((err) => {
      console.error(err.stack);
      process.exit(1);
  })
    .then(async client => {
        console.log(FBrainUsersDAOs.injectDB(client))

        await FBrainUsersDAOs.injectDB(client);
        app.listen(port, () => {
            console.log(`listening on port ${port}`);
        });
    });

Here’s the error message:
image

File structure:
image

For context

Thanks. I wrote it as the other thread was getting too long. Thanks for replying here as well.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.