Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
What does mongodb is not a function mean?

I'm new to programming, I'm trying to follow a web developemnt course when connecting to database I created I get the error "mongodb.connect is not a function".

I try to connect to the database using the following code.

        let mongodb = require('mongodb');
        let db
        let connectionString = '';
        mongodb.connect(connectionString,{useNewUrlParser: true, useUnifiedTopology: 
        true},function(err, client){
        db = client.db();
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can connect to the database from the client (which uses MongoClient from the library).

const { MongoClient } = require('mongodb');

let db;

const connectionString = 'mongodb://' // Change this to your uri
const client = new MongoClient(connectionString)

Then you can connect

await client.connect();
db = client.db();
about 4 years ago · Juan Pablo Isaza Report

0

Try this:

const { MongoClient } = require("mongodb");

let databaseName = '';
let connectionString = '';

MongoClient.connect(connectionString, {useNewUrlParser: true, useUnifiedTopology: true}, (error, client) => {
  if (error) 
    return console.log("Connection failed for some reason");

  const db = client.db(databaseName);
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!