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

$project to have ability to get data from referenced collections (SQL-like "join")

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

      Aggregation framework looks very promising for manipulation of results from read query prior to passing back to the client. It would be great if a facility similar to SQL: "fields:

      { collection1.field1, collection2.field2 }

      , joinOn:

      { collection1.refSourceField, collection2.refTargetField }

      was available. In effect the syntax for $join or similar would have the developer specify:

      • What field they want to get from a target or referenced collection
      • What field in their source collection has a look-up to the target collection
      • What field in the target collection is referenced from the source.

      Obviously this is only useful in cases where data is not denormalized...enterprise systems with large numbers of master data updates cannot denormalize fully because of the pain of mass updates. For example if we have two collections:

      1. Employee.ID = mongoID & Employee.name.fullName = "Fred Flintstone"
      2. Project.ID = mongoID & Project.responsibleMgr = mongoID of the employee who is the project manager
      (assume Employee.name.fullName is not denormalized because it is referenced many times and people get married/change names)

      When reading the Project collection we can only get the mongo ID of the project mgr which is not that useful. If the client does a second read of Employee where ID = Project.responsibleMgr to get their name this is ok but extra burden on the client-ui developer and two http requests. Of course a custom api on the server would avoid the two http requests but is again more work.

      It would be great if in this example we can use $join notation to say something like "fields:

      { Project.ID, Project.responsibleMgr, Employee.name.fullName }

      , joinOn:

      { Employee.ID, Project.responsibleMgr }

      " and get everything back at once from one query.

            Assignee:
            Unassigned Unassigned
            Reporter:
            richard.minney Richard Minney
            Votes:
            4 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: