log4js-node-mongodb
log4js-node-mongodb copied to clipboard
Handle undefined db on connect
Added an if statement to check if db is defined before attempting to use it in the connect method. Also added an option for skipping errors on insert in included commits but removed them. Removed connection string config from error message, to rely just on MongoDB error object for debugging (relevant to my project).
So, basically, just added the db check to the connect method. Feel free to skip the other stuff, I was just prototyping some stuff for a project.
Thanks for the pull request. I guess I will merge the db check. Just out of curiosity. What is your scenario that MongoClient.connect() callback is called with no error, but the db object is null or undefined. Sounds like a weird combination.
There was an error, but the connect() method continues to try and use the db object that may not be defined. So, you could also return in the if (err) conditional block for the same effect.
Sorry for the delayed response, I'm not getting notifications anymore :(
Ok, no problem. Thanks for the clarification. I will merge the pr after my vacation.