k00k
k00k

Reputation: 17573

MongoDB: why are find and findOne only returning last array element?

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

Upvotes: 2

Views: 863

Answers (1)

spf13
spf13

Reputation: 561

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

Upvotes: 3

Related Questions