Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-1823

Issues about mongodb array and subdocument

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 01112017-cleanup
    • None
    • None

    Description

      First, I have test this on db "test" with auth login, I have create a collection "entities" and then insert a record like this "var single = { "id" : 123, "person" : [

      { "birthday" : "12/3/2013" }

      ] };".
      And then I can't use below command to find this record: "var record = db.entities.findOne(

      {"person[0].birthday": "12/3/2013"}

      );", why? Instead, I can use another command to show record: "var record = db.entities.findOne(

      {"person.birthday": "12/3/2013"}

      );". I think the value of person should be an array, so I can use person[0], but it seems like does not work.
      Interestingly,I can use "record.person[0].birthday" to get value of birthday, but command "record.person.birthday" get nothing.
      Please give me some reply ASAP. Thanks in advance!!!

      Reporter: Kevin Zhang
      E-mail: zxz414644665@163.com

      Attachments

        Activity

          People

            barrie Barrie Segal
            auto auto
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10 years, 26 weeks, 2 days ago