[SERVER-5048] $project to have ability to get data from referenced collections (SQL-like "join") Created: 23/Feb/12 Updated: 25/Jun/15 Resolved: 25/Jun/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Richard Minney | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 4 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
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:
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" 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. |
| Comments |
| Comment by Ian Whalen (Inactive) [ 25/Jun/15 ] |
|
Hi Richard, thanks a lot for filing this feature request and my apologies for the time since it was last updated. I'm going to close this as a Duplicate and link it to our upcoming $lookup feature - we’ve decided to progress along fairly similar lines of your suggestion and provide users with the desired functionality via this new operator in the aggregation pipeline. Please follow along in |