In a similar, though more generalized vein to
SERVER-9406 (treating ObjectIDs as dates) and SERVER-24947 (to- typecasting mechanisms), allowing for the projection of any (or all) sub-component(s) of an ObjectId into discrete fields would allow for easy additional processing on these values. Practical use case: aggregate group results based on machine (hardware ID ± PID) that generated the record, useful for log or other hardware-dependent statistical analysis.
The syntax recommendation comes in two forms, short single-component, or multi-component embedded document:
This would project all components from an ObjectId into an embedded document named parts:
To retrieve specific values, pass a document instead of true:
To retrieve a specific singular value, pass just its name instead of true:
As mentioned in the first paragraph, this is to facilitate use of group operations on ObjectID components. As a side-effect, this would have also resolved
SERVER-9406. (Though automatic casting is nice, explicit is better than implicit.)