Skip to content

Outdated MongoDB Driver API #40744

@AhmedTareek

Description

@AhmedTareek

MDN URL

https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Server-side/Express_Nodejs/Introduction

What specific section or headline is this issue about?

using_databases

What information was incorrect, unhelpful, or incomplete?

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

MongoClient.connect("mongodb://localhost:27017/animals", (err, client) => {
  if (err) throw err;

  const db = client.db("animals");
  db.collection("mammals")
    .find()
    .toArray((err, result) => {
      if (err) throw err;
      console.log(result);
      client.close();
    });
});

What did you expect to see?

The callback-based MongoClient.connect method is deprecated in newer versions of the MongoDB, So I expected code which uses the modern API (Async/Await)

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions