-
Type: Improvement
-
Resolution: Won't Do
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
The #tally method currently does this:
class Band
include Mongoid::Document
field :genres, type: Array
end
Band.create!(genres: [1, 2])
Band.create!(genres: [1, 2])
Band.create!(genres: [1, 3])
Band.tally(:genres)
#=> { [1, 2] => 2,
[1, 3] => 1 }
This is perhaps useful in some cases, but usually you'd want to see Array values split out. I'd like to add this:
Band.tally(:genres, splat_arrays: true)
#=> { 1 => 3,
2 => 2,
3 => 1 }
The change can be done with low complexity.
The default value of :splat_arrays would be false, preserving the existing behavior.
I may call this option "unwind" instead because that's the MongoDB operator name that does this. TBD.
- depends on
-
SERVER-59713 `$unwind` doesn't work on array subdocument fields
- Investigating