concept connection in category mongoDB

This is an excerpt from Manning's book Getting MEAN with Mongo, Express, Angular, and Node.js 2ED.
As well as modeling data, Mongoose adds an entire layer of features on top of MongoDB that are useful for building web applications. Mongoose makes it easier to manage the connections to your MongoDB database and to save and read data. You’ll use all of these features later. Also later in the book, we’ll discuss how Mongoose enables you to add data validation at the schema level, making sure that you allow only valid data to be saved in the database.
Step 2: Bring this file into the application by requiring it in app.js. As the actual process of creating a connection between the application and the database can take a little while, you want to do this early in the setup. Amend the top part of app.js to look like the following code snippet (modifications in bold): const express = require('express'); const path = require('path'); const cookieParser = require('cookie-parser'); const logger = require('morgan'); const favicon = require('serve-favicon'); require('./app_server/models/db'); !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":5,\"ch\":0},{\"line\":5,\"ch\":34}]]"} !@%STYLE%@!
To do this, you need three event listeners and one function to close the database connection. Closing the database is an asynchronous activity, so you need to pass through whatever function is required to restart or end the Node process as a callback. While you’re at it, you can output a message to the console confirming that the connection is closed and the reason why. You can wrap all this in a function called gracefulShutdown in db.js:

This is an excerpt from Manning's book MongoDB in Action, Second Edition: Covers MongoDB version 3.0.
mongostat —Similar to iostat, this utility constantly polls MongoDB and the system to provide helpful stats, including the number of operations per second (inserts, queries, updates, deletes, and so on), the amount of virtual memory allocated, and the number of connections to the server.
If you’re building an application using MongoDB’s replication, you need to know about several application-specific topics. The first is related to connections and failover. Next comes the write concern, which allows you to decide to what degree a given write should be replicated before the application continues. The next topic, read scaling, allows an application to distribute reads across replicas. Finally, we’ll discuss tagging, a way to configure more complex replica set reads and writes.
When connecting to a MongoDB replica set in this way, drivers will automatically discover additional nodes. This means that when you’re connecting to a replica set, you don’t need to explicitly list every member of the set. The response from the isMaster command alerts the driver of the presence of the other members. If none of the replica set members listed in the connection arguments are active, the connection will fail, so it’s wise to list as many as you can. But don’t sweat it if a few nodes are missing from the connection list; they’ll be found. If you have multiple data centers, it’s considered good practice to include members from all data centers.
Wed Mar 2 15:43:28 [initandlisten] waiting for connections on port 27020 Wed Mar 2 15:43:28 [websvr] web admin interface listening on port 28020