I split these apart because I'm unsure if you will want both, or one, or the other - so tried to make this easier.
If you enable auth on your mongo server (and you should have if you're going anywhere near production of course...) then you'll put your user in the admin database.
When we connect and pass the db: 'test' option, mongo attempts to use that test db as the auth database however this isn't correct cause we of course put our user in the admin database, not test.
The solution is to simply provide authSource in the connection url - if this doesn't apply then authSource could simply be set to (or maybe even default to) the same as the db option.
Thanks again, hope this is useful - feel free to discuss of course 😄
Hey, another contribution in parallel to #36.
I split these apart because I'm unsure if you will want both, or one, or the other - so tried to make this easier.
If you enable auth on your mongo server (and you should have if you're going anywhere near production of course...) then you'll put your user in the
admin
database.When we connect and pass the
db: 'test'
option, mongo attempts to use thattest
db as the auth database however this isn't correct cause we of course put our user in theadmin
database, nottest
.The solution is to simply provide authSource in the connection url - if this doesn't apply then authSource could simply be set to (or maybe even default to) the same as the
db
option.Thanks again, hope this is useful - feel free to discuss of course 😄