Closed i0na-k closed 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
It was because I was using the wrong url - I need to use: var url = 'mongodb://localhost:27017/' + process.argv[2];
var url = 'mongodb://localhost:27017/' + process.argv[2];
The instructions should ideally make us aware of this.
Here is my solution to the UPDATE exercise:
Also i am console.log url just for debugging and nothing is being outputted to the terminal - is console.log disabled by design? Thanks