Categories
JavaScript Answers

How to check Node Mongoose connection state without creating a new connection?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.