13

I have A Mongoose Connection and at some point in my program I need to close it. after logging the mongoose object several times, I have found that the following workd

mongoose.connection.base.connections[1].close();

Is There A Cleaner way to do this?

mkoryak
  • 55,751
  • 59
  • 197
  • 255
Ari Porad
  • 2,714
  • 3
  • 33
  • 51

1 Answers1

43

To close all connections in the Mongoose connection pool:

mongoose.disconnect();

Docs here.

JohnnyHK
  • 290,447
  • 61
  • 595
  • 453