MongoDB & Mongoose accessing one database while authenticating against another (NodeJS, Mongoose)

前端 未结 2 922
执念已碎
执念已碎 2021-02-10 06:26

I have a few databases and didn\'t want to create separate user accounts for each one. MongoDB supports the notion of authenticating access to a database using accounts defined

2条回答
  •  故里飘歌
    2021-02-10 06:53

    This can also can be simplified by modifying the connection string in the mongodb itself:

    For eg: mongodb://username:password@IP:Port/mydbname?authSource=admin since mongoose supports this connection string provided by mongodb https://docs.mongodb.com/manual/reference/connection-string/#urioption.authSource

提交回复
热议问题