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

Provide way to give counts of array attributes in projection

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 1.5.1
    • Component/s: Querying
    • Labels:
      None
    • Query

      Obtaining counts for large attributes can be a pain. Approaches are to:
      1) Return the entire array and examine length
      2) group/reduce and output the length
      3) map/reduce to get length
      4) ensure documents maintain length attribute across document lifespan

      I think being able to request embedded array length directly would be helpful.

      Perhaps something like:
      db.collection.find({}, {some_array: {$count: true}})

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            crudson Doug Hudson
            Votes:
            8 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: