MongoDB的:为什么找到并findOne只有最后一个数组元素返回? [英] MongoDB: why are find and findOne only returning last array element?

查看:1313
本文介绍了MongoDB的:为什么找到并findOne只有最后一个数组元素返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么当我做了findOne(同样与find),不是只显示我在我的行为数组的最后一个项目。我的收藏中只包含用于测试目的一个文档。

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.

我在蒙戈CLI这样做:db.mycollection.findOne();

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

我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"
        }
    ]
}

下面是我的文档:

 {
  "_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"
    }
  ]
}

编辑:修正了文件 - 有一个错字

推荐答案

MongoHub真的是马车。请不要使用它。 RockMongo和成吉思汗都相当不错。

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

这篇关于MongoDB的:为什么找到并findOne只有最后一个数组元素返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆