There are many things (and a basic API) that I personally love to see in the aggregation structure, for example:
Math functions
- log (as in the logarithm)
- Ceil
- floor
Array
Line
Just to name a few.
And this does not resort to the obscure customs of the $mod operator or other means in such cases as "ceil" and "floor". But I'm distracted.
Your "string length" falls into this category. Raise a JIRA question about this. But now you can use mapReduce and existing JavaScript functions:
db.collection.mapReduce( function() { emit( this.item.length, this.item ); }, function(key,values) { return values; }, { "out": { "inline": 1 } } )
So, while in fact they have a mapReduce funky style that returns a re-issued document and, of course, all that matches the same array length, what it does is use the nature of βmapReduceβ ( not limited to MongoDB only) and allows you to emit a "key" value in the response.
source share