seanemmer / mongoose-seed

Seed data population for Mongoose
MIT License
52 stars 33 forks source link

Fix when the mongoose connection already exists #4

Closed pravin-d closed 8 years ago

pravin-d commented 8 years ago

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.

seanemmer commented 8 years ago

Thanks for contributing to the package pravin - let me know if you have any other ideas!