seanemmer / mongoose-seed

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

Can now pass connection options to seeder. Mongoose takes either 2 o… #16

Closed stephenhuey closed 7 years ago

stephenhuey commented 7 years ago

This fix enables the seeder to take connection options. I had been using the seeder locally but then set up a multi-node MongoDB on a remote server and noticed there was no way for me to pass connection options with mongos. For example:

mongooseOptions = { mongos: { poolSize: 5, reconnectTries: 1000 } }

There was no way for me to run seeder against that MongoDB without passing options containing the mongos attribute. I've tested that my changes work with a multi-node db.

I also noticed that the Mongoose connect function's TypeScript declaration had both a 2-parameter version and a 3-parameter version. I'm open to you changing this code any way you see fit to handle the variable number of parameters for the seeder connect function, but it just needs to be able to take options somehow. I followed your shorthand style (db and cb) and used the variable name opts.

stephenhuey commented 7 years ago

Also should've clarified that the existing documentation would still be correct and you'd just need to add a bit of documentation to demonstrate how to pass 3 parameters (options too).