I have a route which I use for seeding the database. However as I'm using express and the whole app is designed in such a way that the mongoose connection happens on startup. So when I try to seed, I get a connection error "Error: Trying to open unclosed connection.".
In the following fix, I don't attempt to connect if the connection is already established.
Please review and accept the pull-request as I would need the updates on npm too.
I have a route which I use for seeding the database. However as I'm using express and the whole app is designed in such a way that the mongoose connection happens on startup. So when I try to seed, I get a connection error "Error: Trying to open unclosed connection.". In the following fix, I don't attempt to connect if the connection is already established. Please review and accept the pull-request as I would need the updates on npm too.