[SOLVED] Why does my collection data not appear in the Mongo shell?

I want to insert some dummy data on startup. I have created the following collection:


Notes = new Mongo.Collection('Notes');

On startup I am inserting some data into the collection (just one item for now):


    Meteor.startup(() => {
        title: "a test title"

However, when I try to check for items in my Mongo console, I get nothing:

$ meteor mongo               
MongoDB shell version: 2.6.7
connecting to:
meteor:PRIMARY> db.notes.find()

Btw, I get the same result when trying this with the sample todos app. In that case, the fixture data is clearly being generated (you can see it in your browser), but when attempting to find it via the Mongo shell, you get nothing.

Is there something I’m missing here about how the Mongo shell works?

Could you try db.Notes.find()

Note the “capital” “N”


Yup, that was the issue. I had a feeling it was something ridiculously simple like that. Thx!

1 Like

Although that does raise a separate issue: why does the Mongo shell not return any type of error when I am querying a collection that doesn’t exist? (Ie ‘notes’ in my case)

I think there’s a few reasons for that, but for starters that wouldn’t do you too much good in code. I always show collections if I think I should be returning something. db.Notes.exists() also works, since it will return null if it doesn’t exist, or an object with the name if it does.

I am having the same issue, although using a capital gives me the same result. Nada.

It almost seems like there are two instances of the database being created. From the mongo console, I get nothing from db.Places.find(), but Places.find() in my server code returns documents.

Any ideas?

The Places in the Mongo console command db.Places.find() comes from the string name used when defining the collection. So

Places = new Mongo.Collection('codfish');

means that in Meteor you do things like return Places.find();. However, in the Mongo console you would do db.codfish.find().