kmongo / org.litote.kmongo / kotlin.reflect.KProperty

Extensions for kotlin.reflect.KProperty

addToSet

Gets a field name for a $group operation representing all unique values that results from applying the given expression to each document in a group of documents that share the same group by key.

infix fun <T> KProperty<T>.addToSet(expression: T): BsonField

all

Creates a filter that matches all documents where the value of a property is an array that contains all the specified values.

infix fun <T> KProperty<Iterable<T>?>.all(values: Iterable<T>): Bson
fun <T> KProperty<Iterable<T>?>.all(vararg values: T): Bson

arrayElemAt

$arrayElemAt aggregator operator support.

fun KProperty<*>.arrayElemAt(index: Int = 0): Bson

avg

Gets a field name for a $group operation representing the average of the values of the given expression when applied to all members of the group.

infix fun <T> KProperty<T>.avg(expression: T): BsonField

bitsAllClear

Creates a filter that matches all documents where all of the bit positions are clear in the property.

infix fun <T> KProperty<T>.bitsAllClear(bitmask: Long): Bson

bitsAllSet

Creates a filter that matches all documents where all of the bit positions are set in the property.

infix fun <T> KProperty<T>.bitsAllSet(bitmask: Long): Bson

bitsAnyClear

Creates a filter that matches all documents where any of the bit positions are clear in the property.

infix fun <T> KProperty<T>.bitsAnyClear(bitmask: Long): Bson

bitsAnySet

Creates a filter that matches all documents where any of the bit positions are set in the property.

infix fun <T> KProperty<T>.bitsAnySet(bitmask: Long): Bson

contains

Creates a filter that matches all documents where the value of the property contains the specified value. Note that this doesn't actually generate a $eq operator, as the query language doesn't require it.

infix fun <T> KProperty<Iterable<T?>?>.contains(value: T?): Bson

count

Gets a field name for a $group operation representing the count of the values of the given expression when applied to all members of the group.

val KProperty<*>.count: BsonField

Creates a $count pipeline stage using the named field to store the result

fun <T> KProperty<T>.count(): Bson

dateToString

$dateToString aggregator operator support.

fun KProperty<TemporalAccessor?>.dateToString(format: String? = "%Y-%m-%d", zoneId: ZoneId? = null, onNull: String? = null): Bson

elemMatch

Creates a filter that matches all documents containing a property that is an array where at least one member of the array matches the given filter.

infix fun <T> KProperty<Iterable<T>?>.elemMatch(filter: Bson): Bson

elemMatchProj

Creates a projection that includes for the given property only the first element of an array that matches the query filter. This is referred to as the positional $ operator.

fun <T> KProperty<T>.elemMatchProj(): Bson

Creates a projection that includes for the given property only the first element of the array value of that field that matches the given query filter.

fun <T> KProperty<T>.elemMatchProj(filter: Bson): Bson

eq

Creates a filter that matches all documents where the value of the property equals the specified value. Note that this doesn't actually generate a $eq operator, as the query language doesn't require it.

infix fun <T> KProperty<T?>.eq(value: T?): Bson

exists

Creates a filter that matches all documents that contain the given property.

fun <T> KProperty<T>.exists(): Bson

Creates a filter that matches all documents that either contain or do not contain the given property, depending on the value of the exists parameter.

infix fun <T> KProperty<T>.exists(exists: Boolean): Bson

first

Gets a field name for a $group operation representing the value of the given expression when applied to the first member of the group.

infix fun <T> KProperty<T>.first(expression: T): BsonField

from

Creates a projection of a property whose value is computed from the given expression.

infix fun <T> KProperty<T>.from(expression: T): Bson

geoIntersects

Creates a filter that matches all documents containing a property with geospatial data that intersects with the specified shape.

infix fun <T> KProperty<T>.geoIntersects(geometry: Geometry): Bson
infix fun <T> KProperty<T>.geoIntersects(geometry: Bson): Bson

geoWithin

Creates a filter that matches all documents containing a property with geospatial data that exists entirely within the specified shape.

infix fun <T> KProperty<T>.geoWithin(geometry: Geometry): Bson
infix fun <T> KProperty<T>.geoWithin(geometry: Bson): Bson

geoWithinBox

Creates a filter that matches all documents containing a property with grid coordinates data that exist entirely within the specified box.

fun <T> KProperty<T>.geoWithinBox(lowerLeftX: Double, lowerLeftY: Double, upperRightX: Double, upperRightY: Double): Bson

geoWithinCenter

Creates a filter that matches all documents containing a property with grid coordinates data that exist entirely within the specified circle.

fun <T> KProperty<T>.geoWithinCenter(x: Double, y: Double, radius: Double): Bson

geoWithinCenterSphere

Creates a filter that matches all documents containing a property with geospatial data (GeoJSON or legacy coordinate pairs) that exist entirely within the specified circle, using spherical geometry. If using longitude and latitude, specify longitude first.

fun <T> KProperty<T>.geoWithinCenterSphere(x: Double, y: Double, radius: Double): Bson

geoWithinPolygon

Creates a filter that matches all documents containing a property with grid coordinates data that exist entirely within the specified polygon.

infix fun <T> KProperty<T>.geoWithinPolygon(points: List<List<Double>>): Bson

gt

Creates a filter that matches all documents where the value of the given property is greater than the specified value.

infix fun <T> KProperty<T?>.gt(value: T): Bson

gte

Creates a filter that matches all documents where the value of the given property is greater than or equal to the specified value.

infix fun <T> KProperty<T?>.gte(value: T): Bson

hashedIndex

Create an index key for a hashed index on the given property.

fun <T> KProperty<T>.hashedIndex(): Bson

ifNull

$ifNull aggregator operator support.

fun KProperty<*>.ifNull(defaultValue: Any): Bson

in

Creates a filter that matches all documents where the value of a property equals any value in the list of specified values.

infix fun <T> KProperty<T?>.in(values: Iterable<T?>): Bson
infix fun <T> KProperty<T>.in(expression: String): Bson
infix fun <T> KProperty<Iterable<T>?>.in(values: Iterable<T?>): Bson

last

Gets a field name for a $group operation representing the value of the given expression when applied to the last member of the group.

infix fun <T> KProperty<T>.last(expression: T): BsonField

lt

Creates a filter that matches all documents where the value of the given property is less than the specified value.

infix fun <T> KProperty<T?>.lt(item: T): Bson

lte

Creates a filter that matches all documents where the value of the given property is less than or equal to the specified value.

infix fun <T> KProperty<T?>.lte(value: T): Bson

max

Gets a field name for a $group operation representing the maximum of the values of the given expression when applied to all members of the group.

infix fun <T> KProperty<T>.max(expression: T): BsonField

metaTextScore

Creates a projection to the given property of the textScore, for use with text queries.

fun <T> KProperty<T>.metaTextScore(): Bson

min

Gets a field name for a $group operation representing the minimum of the values of the given expression when applied to all members of the group.

infix fun <T> KProperty<T>.min(expression: T): BsonField

mod

Creates a filter that matches all documents where the value of a property divided by a divisor has the specified remainder (i.e. perform a modulo operation to select documents).

fun <T> KProperty<T>.mod(divisor: Long, remainder: Long): Bson

ne

Creates a filter that matches all documents where the value of the field name does not equal the specified value.

infix fun <T> KProperty<T?>.ne(value: T?): Bson

near

Creates a filter that matches all documents containing a property with geospatial data that is near the specified GeoJSON point.

fun <T> KProperty<T>.near(geometry: Point, maxDistance: Double? = null, minDistance: Double? = null): Bson
fun <T> KProperty<T>.near(geometry: Bson, maxDistance: Double? = null, minDistance: Double? = null): Bson

Creates a filter that matches all documents containing a property with geospatial data that is near the specified point.

fun <T> KProperty<T>.near(x: Double, y: Double, maxDistance: Double? = null, minDistance: Double? = null): Bson

nearSphere

Creates a filter that matches all documents containing a property with geospatial data that is near the specified GeoJSON point using spherical geometry.

fun <T> KProperty<T>.nearSphere(geometry: Bson, maxDistance: Double? = null, minDistance: Double? = null): Bson
fun <T> KProperty<T>.nearSphere(geometry: Point, maxDistance: Double? = null, minDistance: Double? = null): Bson

Creates a filter that matches all documents containing a property with geospatial data that is near the specified point using spherical geometry.

fun <T> KProperty<T>.nearSphere(x: Double, y: Double, maxDistance: Double? = null, minDistance: Double? = null): Bson

nin

Creates a filter that matches all documents where the value of a property does not equal any of the specified values or does not exist.

infix fun <T> KProperty<T?>.nin(values: Iterable<T?>): Bson
infix fun <T> KProperty<Iterable<T>?>.nin(values: Iterable<T?>): Bson

path

Returns a mongo path of a property.

fun <T> KProperty<T>.path(): String

projection

The projection of the property.

val <T> KProperty<T>.projection: String

push

Gets a field name for a $group operation representing an array of all values that results from applying an expression to each document in a group of documents that share the same group by key.

infix fun <T> KProperty<T>.push(expression: T): BsonField

regex

Creates a filter that matches all documents where the value of the property matches the given regular expression pattern.

infix fun KProperty<String?>.regex(regex: String): Bson
infix fun KProperty<String?>.regex(regex: Pattern): Bson
infix fun KProperty<String?>.regex(regex: Regex): Bson
infix fun KProperty<Iterable<String?>>.regex(regex: String): Bson
infix fun KProperty<Iterable<String?>>.regex(regex: Pattern): Bson
infix fun KProperty<Iterable<String?>>.regex(regex: Regex): Bson

Creates a filter that matches all documents where the value of the option matches the given regular expression pattern with the given options applied.

fun KProperty<String?>.regex(pattern: String, options: String): Bson
fun KProperty<Iterable<String?>>.regex(pattern: String, options: String): Bson

setTo

Generates a SetTo used in updateOne or updateMany operations.

infix fun <T> KProperty<T>.setTo(value: T): SetTo<T>

size

Creates a filter that matches all documents where the value of a property is an array of the specified size.

infix fun <T> KProperty<T>.size(size: Int): Bson

slice

Creates a projection to the given property of a slice of the array value of that field.

fun <T> KProperty<T>.slice(limit: Int): Bson
fun <T> KProperty<T>.slice(skip: Int, limit: Int): Bson

sortByMetaTextScore

Create a sort specification for the text score meta getProjection on the given property.

fun <T> KProperty<T>.sortByMetaTextScore(): Bson

stdDevPop

Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.

infix fun <T> KProperty<T>.stdDevPop(expression: T): BsonField

stdDevSamp

Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.

infix fun <T> KProperty<T>.stdDevSamp(expression: T): BsonField

sum

Gets a field name for a $group operation representing the sum of the values of the given expression when applied to all members of the group.

infix fun <T> KProperty<T>.sum(expression: T): BsonField

textIndex

Create an index key for a text index on the given property.

fun <T> KProperty<T>.textIndex(): Bson

type

Creates a filter that matches all documents where the value of the property is of the specified BSON type.

infix fun <T> KProperty<T>.type(type: BsonType): Bson

unwind

Creates a $unwind pipeline stage for the specified field name, which must be prefixed by a '$' sign.

fun <T> KProperty<T>.unwind(unwindOptions: UnwindOptions = UnwindOptions()): Bson

variable

Defines a Variable projection (ie $$name)

val KProperty<*>.variable: String

variableDefinition

Defines a Variable for the lookup operator.

fun KProperty<*>.variableDefinition(name: String = path()): Variable<String>