Add support for $rand aggregation operator. #3724
Labels
in: aggregation-framework
Aggregation framework support
status: first-timers-only
An issue that can only be worked on by brand new contributors
type: enhancement
A general enhancement
Milestone
This is a
first-timers-only
issue.This means we've worked to make it more legible to folks who either haven't contributed to our codebase before or even folks who haven't contributed to open source before.
If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!
If you have contributed before, consider leaving this one for someone new, and looking through our general
ideal-for-contribution
issues.Thanks!
Problem
MongoDB 4.4.2 introduced a new aggregation operator
$rand
that we want to support via the Aggregation Framework.Details about the operator can be found within the MongoDB Reference Documentation.
Solution
Introduce
MathOperators
to theorg.springframework.data.mongodb.core.aggregation
package and add aRand
type that implementsAggregationExpression
. You may want to have a look atArithmeticOperators
to get an impression what this could look like.Update
org.springframework.data.mongodb.core.spel.MethodReferenceNode
to add SpEL support for the operator via arand()
method.Make sure to provide tests that assert the expression can be used within an pipeline and produces the desired command.
Again you may want to have a look at existing examples (eg.
ArithmeticOperatorsUnitTests
&SpelExpressionTransformerUnitTests
).Steps to Fix
The text was updated successfully, but these errors were encountered: