What is the assert in the mongodb4.0.3 official connection example?

I"m not sure what assert is. Which god will answer it?

here is an example of a connection to an official document

const MongoClient = require("mongodb").MongoClient;
const assert = require("assert");

// Connection URL
const url = "mongodb://localhost:27017";

// Database Name
const dbName = "myproject";

// Create a new MongoClient
const client = new MongoClient(url);

// Use connect method to connect to the Server
client.connect(function(err) {
  assert.equal(null, err);
  console.log("Connected successfully to server");

  const db = client.db(dbName);

  client.close();
});


Sep.16,2021

assertion library, assert.equal (null, err) means that when err sometimes, it will directly throw the wrong


this is the knowledge of NodeJS. Reference documentation: https://nodejs.org/api/assert.

Menu