2

Why when I do a findOne (same with find), does it only show me the last item in my "acts" array. My collection only contains one document for test purposes.

I'm doing this in the mongo cli: db.mycollection.findOne();

My result of findOne():

{
    "_id" : ObjectId("4f0db64659d044892271018f"),
    "title" : "Awards Show 2012",
    "description" : "An amazing awards show",
    "acts" : [
        {
            "name" : "Act 3",
            "description" : "My act description"
        }
    ]
}

Here is my document:

 {
  "_id": { "$oid" : "4F0DB64659D044892271018F" },
  "title": "Awards Show 2012",
  "description": "An amazing awards show",
  "acts": [
    {
      "name": "Act 1",
      "description": "My act description"
    },
    {
      "name": "Act 2",
      "description": "My act description"
    },
    {
      "name": "Act 3",
      "description": "My act description"
    }
  ]
}

EDIT: Fixed the document - had a typo

3
  • 2
    if findOne returns a document with only one item, and find does the same, how do you know 'your document' is in the database at all? Commented Jan 11, 2012 at 19:09
  • Because I am also using MongoHub (gui for mac). And I can browse my collection and expand my document. Screenshot: i.imgur.com/uEojd.png Commented Jan 11, 2012 at 19:15
  • I think I might have found the problem. I don't think the document was being inserted by MongoHub properly. Troubleshooting, I'll be back with more detail shortly. Commented Jan 11, 2012 at 19:21

1 Answer 1

3

MongoHub is really buggy. Please don't use it. RockMongo and Genghis are quite good.

Sign up to request clarification or add additional context in comments.

4 Comments

Yep, it was MongoHub that was screwing up. I was inserting via MongoHub and it said it was inserting all of the array elements, and even returning that on a find, but Mongo client proved different. I'll check out RockMongo and Genghis.
Just checked them out. I would prefer a GUI for Mac so I don't have to rely on rails or PHP.
Unfortunately there isn't a really good GUI for Mac yet. There's a good one that's Windows specific called MongoVUE, but that won't help you. For the most part the web ones are further along for cross platform use.
Genghis 2.0 has been released and no longer depends on PHP or apache. There is a ruby gem for it and it's completely self contained. Works well cross platform.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.