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

Aggregate on multiple collections

    • Type: Icon: New Feature New Feature
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None

      another way to implement cross-collections joins.
      ex: 2 collections: Books and Authors.

      book = { _id:1, title: 'A', author_id: 1 }
      author = { _id: 1, name: 'Me' }
      
      db.aggregate(
       {$collection: 'book', $match: ...},
       {$collection: 'author', $match: ...},
       ...
       {$group: ...},
       {$project: ...}
      )
      

      in result (example too):

      books_with_authors = [
       {_id:1, title: 'A', author: { _id: 1, name: 'Me' }},
       ...
      ]
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            funvit Vitaliy F.
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: