Wednesday, 7 June 2017

Mongoose connect throwing an warning

I am writing a mongodb connected app and while connecting to the server like bellow getting a warning like this:

Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.

My codes are like bellow

import mongoose from 'mongoose';
import config from './config';
mongoose.connect(config.db.uri);

at config.js

const config = {
    name: 'API',
    version: '0.0.1',
    env: process.env.NODE_ENV || 'development',
    port: process.env.PORT || 3000,
    base_url: process.env.BASE_URL || 'http://localhost:3000',
    db: {
        uri: 'mongodb://admin:harry123@127.0.0.1:27017/ai?authSource=admin',
    },
}

export default config;



via Dave B

No comments:

Post a Comment