Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lesson fails, even with correct solution #31

Open
icodejs opened this issue Feb 18, 2016 · 2 comments
Open

Update lesson fails, even with correct solution #31

icodejs opened this issue Feb 18, 2016 · 2 comments

Comments

@icodejs
Copy link

icodejs commented Feb 18, 2016

Hey,

While working on the update lesson, I wasn't able to get my code to pass, so I tried your solution and still had no luck.

I not sure if it has something to do with the versions of Node or Mongodb.

Let me know if this is enough information:

Mongodb version v3.2.1
Node v4.2.3

My solution: https://github.com/icodejs/nodeschool/blob/master/learnyoumongo/06-UPDATE/solution.js
Your solution: https://github.com/evanlucas/learnyoumongo/blob/master/exercises/update/solution/solution.js

Thanks!

@Bubbit
Copy link

Bubbit commented Feb 20, 2016

I have the same problem:

Mongodb v2.1.7
Node v5.1.0

@kazzacarrot
Copy link
Contributor

My solution didn't pass the tests. I saw these comments and doubted the test. So, I pimped out my solution to log tinas record before and after I updated it. I saw her age change from 30 to 40 and when I ran verify, it worked!
I thought I would share my working solution.

var mongo = require('mongodb').MongoClient
var url = "mongodb://localhost:27017/" + process.argv[2];
mongo.connect(url, function(err, db) {
    if (err) throw err;
    docs =  db.collection('users')
    tina = {
          username: "tinatime"
        }
    docs.find(tina).toArray(function(err, data) {
            if (err) throw err;
            console.log(data);
            docs.update(tina, { $set: {age: 40 }}, function(err
                    if (err) throw err;
                    docs.find(tina).toArray( function(err, data) {
                            if (err) throw err;
                            db.close()
                            console.log(data);
                        })
                })
    })
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants