Subset of an array with conditionals

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      If I have a document
      {
      title : "My First Post", author: "Jane",
      comments : [

      { by: "Abe", text: "First" }

      ,

      { by : "Ada", text : "Good post" }

      ]
      }
      The query:
      > db.blogposts.find(

      { "comments.by" : "Ada" }

      )
      returns the entire comments document. If there are many elements in an array I would probably have to go through the entire array in my caller code and get the
      right element. Although the index on embedded docs would find the document fast, it would be nice to have a conditional that returns only those elements of an array that are asked for. This would really avoid duplication of the search through the array in the calling client code.

            Assignee:
            Eliot Horowitz (Inactive)
            Reporter:
            Sid
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: