To check Node Mongoose connection state without creating a new connection, we get the connection
property.
For instance, we write
require("./app.js");
const mongoose = require("mongoose");
console.log(mongoose.connection.readyState);
to get the mongoose.connect.readyState
property to check if the Mongoose connection is ready.