It is not clear what assert is. Which great god will answer it?
The following 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();
});
Assertion library,
assert.equal(null, err)
Indicates whenerr
Sometimes, it will be thrown directly wrong.