Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialUday Ramakrishna
226 PointsMongo collection returns blank
Hi,
I just started learning mongo here and was hoping to apply this to a work situation. I have a collection called sessions where when i go db.sessions.count() i see 2 records but when i do db.sessions.find() i receive no response. Any thoughts on why this might be the case?
6 Answers
Ken Alger
Treehouse TeacherUday;
Which version of MongoDB are you using?
Ken
Ken Alger
Treehouse TeacherGreat. Thanks for that.
I find it odd as well that doing a db.sessions.find()
returns nothing. What happens if you do a db.sessions.findOne()
? Do you get a result from that?
Are you attempting to run these commands in the Mongo Shell?
Ken
Uday Ramakrishna
226 PointsHi Ken,
Yes, i was running these from command line. Looks like the database i was trying to access did not have much data in it. Since i am learning as well as trying to apply, i found a php solution to try and view the data in this database which helped me get a peek at the underlying data which turned out to be blank except the index. Thanks for checking in. But i think i will need to try more as i cant reproduce the exact issue.
Best Regards Uday
Ken Alger
Treehouse TeacherUday;
No problem at all. I would recommend generating some test data quickly from the Mongo Shell just to make sure if you still have concerns. Small datasets can sometimes lead to strange results, but you should still be able to do a find()
and have the returned cursor display all of the documents in the collection, even if those documents only contain an _id
field.
Please post back if you still have additional issues or questions. And congratulations on working with MongoDB!
Best wishes and happy coding, Ken
Uday Ramakrishna
226 PointsThank you for the quick response Ken. I will certainly drop a note here should i encounter any further issues. I used http://www.phpmongodb.org to take a peek at my data and might be useful for others hence listing it here.
Best Regards Uday
Ken Alger
Treehouse TeacherUday;
MongoDB is making a large move towards, and investment in, visual ways to access and manage a MongoDB database. Some of their options are things like Cloud Manager and Ops Manager which are awesome, but likely overkill for what you need. Although I would highly recommend you at least take a look at them.
The other option which might be of use is MongoDB Compass which could be of some use for your current level of use.
Happy coding, Ken
Uday Ramakrishna
226 PointsUday Ramakrishna
226 PointsHi Ken, i am using version 3.0.9 based on the response to db.version();