top
fun <OutExpression> top(property: KProperty<*>, sortBy: Bson, outExpression: OutExpression): BsonField
Returns a combination of a computed field and an accumulator that produces a value of the given {@code outExpression} computed for the top element within a group sorted according to the provided {@code sortBy} specification.
Return
The requested {@link BsonField}. @mongodb.driver.manual reference/operator/aggregation/top/ $top @mongodb.server.release 5.2
Parameters
property
The data class property computed by the accumulator.
sort By
The {@linkplain Sorts sort specification}. The syntax is identical to the one expected by {@link Aggregates#sort(Bson)}.
out Expression
The output expression.