Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.aggregation.operatorsArithmeticValueOperatorsminus

minus

open operator fun <Context : Any, Result> Value<Context, Result>.minus(other: Value<Context, Result>): Value<Context, Result>

Subtracts one aggregation value from another.

The second argument is subtracted from the first argument.

Example

class Sale(
    val price: Int,
    val fee: Int,
    val discount: Int,
    val total: Int,
)

collection.updateManyWithPipeline {
    set {
        Sale::total set (of(Sale::price) + of(Sale::fee) - of(Sale::discount))
    }
}

External resources