Guest User

Untitled

a guest
Apr 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. // "mongoose": "5.0.13",
  2.  
  3. /* ERROR */
  4.  
  5. C:\Users\ZERO\Documents\marcius-capital\server\node_modules\mongoose\lib\utils.js:429
  6. throw err;
  7. ^
  8. MongoError: not authorized on admin to execute command { listIndexes: "users", cursor: { } }
  9. at queryCallback (C:\Users\ZERO\Documents\marcius-capital\server\node_modules\mongodb-core\lib\cursor.js:223:25)
  10. at C:\Users\ZERO\Documents\marcius-capital\server\node_modules\mongodb-core\lib\connection\pool.js:541:18
  11. at process._tickCallback (internal/process/next_tick.js:150:11)
  12. [nodemon] app crashed - waiting for file changes before starting...
  13.  
  14.  
  15. /* CODE SNIPPET */
  16.  
  17. import mongoose from 'mongoose'
  18.  
  19. const USER = 'DB_USER'
  20. const PASSWORD = 'MY_PASSWORD'
  21.  
  22. const URL = `mongodb+srv://${USER}:${PASSWORD}@cluster0-tsozo.mongodb.net/test`
  23.  
  24. mongoose.connection.on('open', () => {
  25. console.log('Connected to mongo server.')
  26. })
  27. mongoose.connection.on('error', (err) => {
  28. console.log('Could not connect to mongo server!')
  29. console.log(err)
  30. })
  31.  
  32. mongoose.Promise = global.Promise
  33.  
  34. mongoose.connect(URL, {
  35. ssl: true,
  36. keepAlive: true,
  37. autoReconnect: true,
  38. })
  39.  
  40. export default mongoose
Add Comment
Please, Sign In to add comment