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

"$exit" aggregation stage (with $cond operator support)

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Trivial - P5
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Aggregation Framework
    • Labels:
      None

      Description

      It would be nice if we could exit out of an Aggregate Pipeline. For example:

      db.books.aggregate([
          {$match:{ _id: ObjectId('5bede977e8dd7e5d5df79dab') }},
          {$limit: 20},
          {$exit: { $cond: [ { $in: ['$genre',['science fiction', 'fantasy']}, true, false ] }},
          {$sort: { created: -1 }} // sort is skipped
      ]);
      

      It would also be nice for debugging longer pipelines:

      db.tapping.aggregate([
          {$match:{ _id: ObjectId('5bede977e8dd7e5d5df79dab') }},
          {$exit: true }, // rest of pipeline would be skipped
          ...
      ]);
      

      Thanks for your consideration.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              jonah@surveyplanet.com Jonah Werre
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

                Dates

                Created:
                Updated: