Skip to content

Latest commit

 

History

History
16 lines (13 loc) · 575 Bytes

mongoose-authorization.md

File metadata and controls

16 lines (13 loc) · 575 Bytes

Authorization for MongoDB in Mongoose

Because they just can't stop breaking their APIs

One who has authorization set up for MongoDB (as described here) might then want to write a Node/Express application that somehow involves the use of Mongoose. This requires an extra step not documented in a number of guides on this subject, but is easy to remedy. Connection should look something like this:

const dbURI = 'mongodb://admin:password@localhost/db?authSource=admin';

mongoose.connect(dbURI, {
  useMongoClient: true
});