[SERVER-22886] $type projection operator (cast types within aggregation pipelines). Created: 29/Feb/16 Updated: 26/Apr/19 Resolved: 29/Feb/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Dylan Piercey | Assignee: | Unassigned |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | Feature | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Participants: | |||||||||
| Description |
|
Currently there is no way to convert types without the aggregation framework. This would be useful to allow things like Dates <-> Timestamps/Strings, Strings <-> Numbers and even cooler stuff like OID <-> String. I think the most intuitive way to add type casting would be to reuse the $type query in the $project stage of the aggregation pipeline which would maybe look something like this:
Where "$my_date" is currently a `Date` bson type and will be casted to a 32-bit integer (16). Perhaps aliases could also be supported to allow for:
Ultimately syntax doesn't matter but I think type casting is something the aggregation framework is lacking which would help many use cases without relying on in app implementations. |
| Comments |
| Comment by Ian Whalen (Inactive) [ 26/Apr/19 ] |
|
Switching "Drivers Changes Needed" from "Maybe" to "Not Needed" since this was closed as something other than Fixed. |
| Comment by Charlie Swanson [ 29/Feb/16 ] |
|
Hi dylanpiercey, Thanks for reporting this issue, but it looks like we already have a similar request in SERVER-6203, so I'm closing this issue as a duplicate. If you do not believe this is a duplicate issue, please feel free to re-open and explain the differences. Thanks |