Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-3045

Subset of an array with conditionals

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None
    • ALL

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: