Hey. I’m trying to run the following code:
const mongoDB = require("mongodb").MongoClient;
exports("createDbClient", () => {
return new mongoDB("mongodb://localhost:27017", { useNewUrlParser: true });
});
const client = exports.foggy_db_api.createDbClient();
client.connect((err) => {
if(!err){
console.log("Connected to DB");
}
else{
console.log(err);
}
});
But I get an error: Error loading script server/main.js in resource foggy_db_api: TypeError: client.connect is not a function
stack: TypeError: client.connect is not a function at server/main.js:19:8
What am i doing wrong?