One of mongodb’s Problems

  node.js, question
var settings = require('../settings'),
 Db = require('mongodb').Db,
 Connection = require('mongodb').Connection,
 Server = require('mongodb').Server;
 module.exports = new Db(settings.db, new Server(, settings.port), {safe: true});

I don’t understand several points in this code. .
Db = require(‘mongodb’).Db and connection = require (‘mongodb’). connection and server = require (‘mongodb’). server and newdb (settings.db, new server (, settings.port), {safe: true}) what are their functions? ? ? Ask for help. Please give us an answer if you know. Thank you!

settingDo you understand the role of? Now let’s talk about the following.
First of all, this is all requiremongodbThis module is the Node.js driver of mongodb, which allows you to connect Mongodb with Node.js for operation.

Db = require('mongodb').Db

Is to export a MongoDb module built-in db method, the following through the new call it to create a database connection instance.

To establish a database connection, you need to specify a name and Server port. This is what the server does:

Server = require('mongodb').Server;

Export a Server method, pass the host and port number through the new method to create a new server instance.
Then{safe: true}Obviously, it is a configuration parameter that specifies some configurations of the database.

As for Connection, it is not used here and has not been exported. ignore it first.

If you say, why do you want to call this, because the document is so specified

However, Mongodb has another simpler connection method, which is to use MongoClient. I just used it two days ago. Please refer to my code:

Or an official statement:

PS: This is the tutorial of the Node blog, I have seen it before. Cheer up.