Search code examples
node.jsmongodbmlab

Connect to Mlab with mongoose


Hi i'm trying to make a simple connection

mongoose.connect('mongodb://JFalcon:john2522@ds119476.mlab.com:19476/hidonshabat', {useMongoClient: true}, function(err){
    if(err) {
        console.log('Some problem with the connection ' +err);
    } else {
        console.log('The Mongoose connection is ready');
    }
})

As you can see this is the url! Please help me


Solution

  • Please correct as follows

    mongoose.connect('mongodb://<dbuser>:<dbpassword>@ds119476.mlab.com:19476/hidonshabat', 
        {useNewUrlParser: true },function(err)=>{
        {
            if(err) {
                console.log('Some problem with the connection ' +err);
            } else {
                console.log('The Mongoose connection is ready');
            }
        })