ComparisonValueOperators¶
interface ComparisonValueOperators : ValueOperators
Operators to compare two values.
To learn more about aggregation operators, view AggregationOperators.
Inheritors¶
Properties¶
context¶
@LowLevelApi
abstract override val context: BsonContext
The strategy used when converting from KProperty1 to Field.
field¶
Converts a Kotlin property into a Field.
Functions¶
div¶
Refers to field as a nested field of the current value.
Examples¶
class User(
val name: String,
)
class Data(
val users: List<User>,
val userNames: List<Int>,
)
data.aggregate()
.set {
Data::userNames set Data::users.map { it / User::name }
}
External resources¶
Refers to field as a nested field of the current value.
Examples¶
class User(
val name: String,
)
class Data(
val users: List<User>,
val userNames: List<Int>,
)
data.aggregate()
.set {
Data::userNames set Data::users.map { it / User::name }
}
External resources¶
eq¶
Compares two aggregation values and returns true if they are equivalent.
Example¶
class Product(
val name: String,
val creationDate: Instant,
val releaseDate: Instant,
)
val releasedOnCreation = collection.aggregate()
.match {
expr {
of(Product::creationDate) eq of(Product::releaseDate)
}
}
.toList()
External resources¶
See also
-
ComparisonValueOperators.ne: Negation of this operator. -
FilterQuery.eq: Equivalent operator in regular queries.
get¶
Refers to a specific item in an array, by its index.
Refers to a specific item in a map, by its name.
Refers to a specific item in an array, by its index.
Refers to a specific item in a map, by its name.
gt¶
gte¶
lt¶
lte¶
ne¶
Compares two aggregation values and returns true if they are not equivalent.
Example¶
class Product(
val name: String,
val creationDate: Instant,
val releaseDate: Instant,
)
val notReleasedOnCreation = collection.aggregate()
.match {
expr {
of(Product::creationDate) eq of(Product::releaseDate)
}
}
.toList()
External resources¶
See also
-
ComparisonValueOperators.eq: Negation of this operator. -
FilterQuery.ne: Equivalent operator in regular queries.
of¶
Refers to a field within an aggregation value.
Example¶
Refers to a field within an aggregation value.
Example¶
Refers to a Kotlin value within an aggregation value.
Example¶
Refers to a BsonType within an aggregation value.
Example¶
unsafe¶
Refers to a field child of the current field, with no compile-time safety.
open infix fun <Root, Child> KProperty1<Root, *>.unsafe(child: KProperty1<*, Child>): Field<Root, Child>
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, with no compile-time safety.