evanlucas / learnyoumongo

MongoDB workshop.
MIT License
306 stars 89 forks source link

Why is my solution to UPDATE not being verified and console.log is not working #70

Closed i0na-k closed 6 years ago

i0na-k commented 6 years ago

Here is my solution to the UPDATE exercise:

var mongoClient = require('mongodb').MongoClient;
var url = process.argv[2];

mongoClient.connect(url,function(err,db){
    if (err) throw err;
    console.log(url);
    db.collection('users').update(
        {"username": "tinatime"},
        {$set: {"age": 40}}, function(err,data){
            if (err) throw err;
            console.log(data);
            db.close();
        });
});

Also i am console.log url just for debugging and nothing is being outputted to the terminal - is console.log disabled by design? Thanks

i0na-k commented 6 years ago

It was because I was using the wrong url - I need to use: var url = 'mongodb://localhost:27017/' + process.argv[2];

The instructions should ideally make us aware of this.