computed

@JvmName(name = "computedFromExt")
infix fun <T> KProperty<T>.computed(expression: Any): Bson

Creates a projection of a property whose value is computed from the given expression. Projection with an expression can be used in the following contexts:

  • $project aggregation pipeline stage.
  • Starting from MongoDB 4.4, it's also accepted in various find-related methods within the {@code MongoCollection}-based API where projection is supported, for example:
    • {@code find()}
    • {@code findOneAndReplace()}
    • {@code findOneAndUpdate()}
    • {@code findOneAndDelete()}

Return

the projection

Parameters

expression

the expression

the expression type

See also

#computedSearchMeta(String)

Aggregates

#project(Bson)


fun <T> computed(property: KProperty<T>, expression: Any): Bson

Creates a projection of a property whose value is computed from the given expression. Projection with an expression can be used in the following contexts:

  • $project aggregation pipeline stage.
  • Starting from MongoDB 4.4, it's also accepted in various find-related methods within the {@code MongoCollection}-based API where projection is supported, for example:
    • {@code find()}
    • {@code findOneAndReplace()}
    • {@code findOneAndUpdate()}
    • {@code findOneAndDelete()}

Return

the projection

Parameters

property

the data class property

expression

the expression

the expression type

See also

#computedSearchMeta(String)

Aggregates

#project(Bson)


@JvmName(name = "computedFromExt")
infix fun String.computed(expression: Any): Bson

Creates a projection of a String whose value is computed from the given expression. Projection with an expression can be used in the following contexts:

  • $project aggregation pipeline stage.
  • Starting from MongoDB 4.4, it's also accepted in various find-related methods within the {@code MongoCollection}-based API where projection is supported, for example:
    • {@code find()}
    • {@code findOneAndReplace()}
    • {@code findOneAndUpdate()}
    • {@code findOneAndDelete()}

Return

the projection

Parameters

expression

the expression

See also

#computedSearchMeta(String)

Aggregates

#project(Bson)


fun computed(property: String, expression: Any): Bson

Creates a projection of a String whose value is computed from the given expression. Projection with an expression can be used in the following contexts:

  • $project aggregation pipeline stage.
  • Starting from MongoDB 4.4, it's also accepted in various find-related methods within the {@code MongoCollection}-based API where projection is supported, for example:
    • {@code find()}
    • {@code findOneAndReplace()}
    • {@code findOneAndUpdate()}
    • {@code findOneAndDelete()}

Return

the projection

Parameters

property

the data class property

expression

the expression

See also

#computedSearchMeta(String)

Aggregates

#project(Bson)