error in learn you mongo exercise 3
See original GitHub issueI’m running from c9.IO, whenever I try to run the selected file with the command “learnyoumongo run file.js” I get the below error.
I tried playing around with the code and I tried it with a blank file, the result is always the same…
/home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/node_modules/mongodb/lib/server.js:235
process.nextTick(function() { throw err; })
^
TypeError: Cannot read property 'collection' of undefined
at Exercise.<anonymous> (/home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/exercises/find/exercise.js:37:5)
at next (/home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/node_modules/workshopper-exercise/exercise.js:260:17)
at Exercise.end (/home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/node_modules/workshopper-exercise/exercise.js:266:5)
at Workshopper.end (/home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/node_modules/workshopper/workshopper.js:191:12)
at Workshopper.done (/home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/node_modules/workshopper/workshopper.js:323:19)
at Exercise.<anonymous> (/home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/node_modules/workshopper-exercise/exercise.js:149:14)
at /home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/node_modules/workshopper-exercise/exercise.js:136:16
at /home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/exercises/find/exercise.js:20:21
at /home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/node_modules/mongodb/lib/mongo_client.js:269:20
at /home/ubuntu/.nvm/versions/node/v4.1.1/lib/node_modules/learnyoumongo/node_modules/mongodb/lib/db.js:226:14
Issue Analytics
- State:
- Created 8 years ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
MongoDB - Excersise 3 (Complete Pain To Work With) - Node
I may have to learn another database framework/lib cause this one is just so error prone without a clear indication whats wrong.
Read more >MongoDB Exercises, Practice, Solution - w3resource
The best way we learn anything is by practice and exercise questions ... Hope, these exercises help you to improve your MongoDB query...
Read more >Chapter 3-New Issue - M001: MongoDB Basics
Going on with the exercise in chapter 3, I think I can now log into Atlas. However, when I run a query I...
Read more >strange mongodb and mongoose error: not master and ...
That means you're trying to read from a secondary node in a replica set, you can only read from the primary node by...
Read more >MongoDB Exercises - W3Schools
Good luck! Start MongoDB Exercises ❯. If you don't know MongoDB, we suggest that you read our MongoDB Tutorial from scratch.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ThomastheBicyclist you would need to run
npm install mongodb
whenever you see that errorWas having same issue and this helped: https://stackoverflow.com/questions/47662220/db-collection-is-not-a-function-when-using-mongoclient-v3-0/47662979
Essentially, the newer version of mongodb has changed how the .connect() method works. It no longer provides a db, but a Client object. You can extract the db from this object by referring to the db by name. For example:
Note how you close the client now, and not the db