Package-level declarations

Types

Link copied to clipboard

List all known mongo operators, used in string templates.

Link copied to clipboard
data class SetTo<out T>(val property: KProperty<T>, val value: T?)

A property set to a new value used in update operations.

Properties

Link copied to clipboard
Link copied to clipboard
val String.bson: BsonDocument

Get the org.bson.BsonValue of this string.

Link copied to clipboard

Returns a collection property.

Link copied to clipboard
val KProperty<*>.count: BsonField

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.

Link copied to clipboard
val EMPTY_BSON: Bson

An immutable empty Bson.

Link copied to clipboard

Get the extended json representation of this object

Link copied to clipboard
val <K, T> KProperty1<out Any?, Map<out K, T>?>.mapProperty: KMapSimplePropertyPath<out Any?, K, T>

Returns a map property.

Link copied to clipboard

The projection of the property.

Link copied to clipboard

Defines a Variable projection (ie $$"myString"")

Defines a Variable projection (ie $$name)

Functions

Link copied to clipboard
fun <T> addEachToSet(property: KProperty<Iterable<T>?>, values: List<T>): Bson

Creates an update that adds each of the given values to the array value of the property, unless the value is already present, in which case it does nothing

Link copied to clipboard
fun addFields(fields: List<Field<*>>): Bson
fun addFields(vararg fields: Field<*>): Bson

Creates an $addFields pipeline stage

Link copied to clipboard
fun <T> addToSet(property: KProperty<Iterable<T>?>, value: T): Bson

Creates an update that adds the given value to the array value of the property, unless the value is already present, in which case it does nothing

Link copied to clipboard
infix fun <T> KProperty<T>.addToSet(expression: T): BsonField

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.

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

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

Link copied to clipboard
fun and(filters: Iterable<Bson?>): Bson
fun and(vararg filters: Bson?): Bson

Creates a filter that performs a logical AND of the provided list of filters. Note that this will only generate a "$and" operator if absolutely necessary, as the query language implicity ands together all the keys. In other words, a query expression like:

Link copied to clipboard
fun arrayElemAt(path: String, index: Int = 0): Bson

$arrayElemAt aggregator operator support.

Link copied to clipboard
fun KProperty<*>.arrayElemAt(index: Int = 0): Bson

$arrayElemAt aggregator operator support.

Link copied to clipboard
fun ascending(properties: List<KProperty<*>>): Bson
fun ascending(vararg properties: KProperty<*>): Bson

Create a sort specification for an ascending sort on the given properties.

Link copied to clipboard
fun ascendingIndex(properties: Iterable<KProperty<*>>): Bson
fun ascendingIndex(vararg properties: KProperty<*>): Bson

Create an index key for an ascending index on the given fields.

Link copied to clipboard
infix fun <T> KProperty<T>.avg(expression: T): BsonField

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.

Link copied to clipboard
infix fun <T> KProperty<T>.bitsAllClear(bitmask: Long): Bson

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

Link copied to clipboard
infix fun <T> KProperty<T>.bitsAllSet(bitmask: Long): Bson

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

Link copied to clipboard
infix fun <T> KProperty<T>.bitsAnyClear(bitmask: Long): Bson

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

Link copied to clipboard
infix fun <T> KProperty<T>.bitsAnySet(bitmask: Long): Bson

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

Link copied to clipboard
fun <T : Number?> bitwiseAnd(property: KProperty<T>, value: Int): Bson
@JvmName(name = "ubytebitwiseAnd")
fun bitwiseAnd(property: KProperty<UByte>, value: Int): Bson
@JvmName(name = "uintbitwiseAnd")
fun bitwiseAnd(property: KProperty<UInt>, value: Int): Bson
@JvmName(name = "ulongbitwiseAnd")
fun bitwiseAnd(property: KProperty<ULong>, value: Int): Bson
@JvmName(name = "ushortbitwiseAnd")
fun bitwiseAnd(property: KProperty<UShort>, value: Int): Bson

Creates an update that performs a bitwise and between the given integer value and the integral value of the property.

fun <T : Number?> bitwiseAnd(property: KProperty<T>, value: Long): Bson
@JvmName(name = "ubytebitwiseAnd")
fun bitwiseAnd(property: KProperty<UByte>, value: Long): Bson
@JvmName(name = "uintbitwiseAnd")
fun bitwiseAnd(property: KProperty<UInt>, value: Long): Bson
@JvmName(name = "ulongbitwiseAnd")
fun bitwiseAnd(property: KProperty<ULong>, value: Long): Bson
@JvmName(name = "ushortbitwiseAnd")
fun bitwiseAnd(property: KProperty<UShort>, value: Long): Bson

Creates an update that performs a bitwise and between the given long value and the integral value of the property.

Link copied to clipboard
fun <T : Number?> bitwiseOr(property: KProperty<T>, value: Int): Bson
@JvmName(name = "ubytebitwiseOr")
fun bitwiseOr(property: KProperty<UByte>, value: Int): Bson
@JvmName(name = "uintbitwiseOr")
fun bitwiseOr(property: KProperty<UInt>, value: Int): Bson
@JvmName(name = "ulongbitwiseOr")
fun bitwiseOr(property: KProperty<ULong>, value: Int): Bson
@JvmName(name = "ushortbitwiseOr")
fun bitwiseOr(property: KProperty<UShort>, value: Int): Bson

Creates an update that performs a bitwise or between the given integer value and the integral value of the property.

fun <T : Number?> bitwiseOr(property: KProperty<T>, value: Long): Bson
@JvmName(name = "ubytebitwiseOr")
fun bitwiseOr(property: KProperty<UByte>, value: Long): Bson
@JvmName(name = "uintbitwiseOr")
fun bitwiseOr(property: KProperty<UInt>, value: Long): Bson
@JvmName(name = "ulongbitwiseOr")
fun bitwiseOr(property: KProperty<ULong>, value: Long): Bson
@JvmName(name = "ushortbitwiseOr")
fun bitwiseOr(property: KProperty<UShort>, value: Long): Bson

Creates an update that performs a bitwise or between the given long value and the integral value of the property.

Link copied to clipboard
fun <T : Number?> bitwiseXor(property: KProperty<T>, value: Int): Bson
@JvmName(name = "ubytebitwiseXor")
fun bitwiseXor(property: KProperty<UByte>, value: Int): Bson
@JvmName(name = "uintbitwiseXor")
fun bitwiseXor(property: KProperty<UInt>, value: Int): Bson
@JvmName(name = "ulongbitwiseXor")
fun bitwiseXor(property: KProperty<ULong>, value: Int): Bson
@JvmName(name = "ushortbitwiseXor")
fun bitwiseXor(property: KProperty<UShort>, value: Int): Bson

Creates an update that performs a bitwise xor between the given integer value and the integral value of the property.

fun <T : Number?> bitwiseXor(property: KProperty<T>, value: Long): Bson
@JvmName(name = "ubytebitwiseXor")
fun bitwiseXor(property: KProperty<UByte>, value: Long): Bson
@JvmName(name = "uintbitwiseXor")
fun bitwiseXor(property: KProperty<UInt>, value: Long): Bson
@JvmName(name = "ulongbitwiseXor")
fun bitwiseXor(property: KProperty<ULong>, value: Long): Bson
@JvmName(name = "ushortbitwiseXor")
fun bitwiseXor(property: KProperty<UShort>, value: Long): Bson

Creates an update that performs a bitwise xor between the given long value and the integral value of the property.

Link copied to clipboard
fun <TExpression, Boundary> bucket(groupBy: TExpression, boundaries: List<Boundary>, options: BucketOptions = BucketOptions()): Bson

Creates a $bucket pipeline stage

Link copied to clipboard
fun <TExpression> bucketAuto(groupBy: TExpression, buckets: Int, options: BucketAutoOptions = BucketAutoOptions()): Bson

Creates a $bucketAuto pipeline stage

Link copied to clipboard
fun combine(updates: List<Bson>): Bson
fun combine(vararg updates: Bson): Bson

Combine a list of updates into a single update.

Link copied to clipboard
fun <BooleanExpression : Any, ThenExpression : Any, ElseExpression : Any> cond(booleanExpression: BooleanExpression, thenExpression: ThenExpression, elseExpression: ElseExpression): Bson

Returns a $cond expression.

Link copied to clipboard
infix fun <T> KProperty<Iterable<T?>?>.contains(value: T?): Bson

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.

Link copied to clipboard
fun <T> KProperty<T>.count(): Bson

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

Link copied to clipboard
fun <T> currentDate(property: KProperty<T>): Bson

Creates an update that sets the value of the property to the current date as a BSON date.

Link copied to clipboard
fun <T> currentTimestamp(property: KProperty<T>): Bson

Creates an update that sets the value of the property to the current date as a BSON timestamp.

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

$dateToString aggregator operator support.

Link copied to clipboard
fun dayOfMonth(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "dayOfMonthObjectId")
fun dayOfMonth(property: KProperty<ObjectId?>): Bson

Builds $dayOfMonth expression for this property .

Link copied to clipboard
fun dayOfWeek(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "dayOfWeekObjectId")
fun dayOfWeek(property: KProperty<ObjectId?>): Bson

Builds $dayOfWeek expression for this property .

Link copied to clipboard
fun dayOfYear(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "dayOfYearObjectId")
fun dayOfYear(property: KProperty<ObjectId?>): Bson

Builds $dayOfYear expression for this property .

Link copied to clipboard
fun <T> deleteMany(filter: Bson, options: DeleteOptions = DeleteOptions()): DeleteManyModel<T>

Creates an DeleteManyModel.

Link copied to clipboard
fun <T> deleteOne(filter: Bson, options: DeleteOptions = DeleteOptions()): DeleteOneModel<T>

Creates an DeleteOneModel.

Link copied to clipboard
fun descending(properties: List<KProperty<*>>): Bson
fun descending(vararg properties: KProperty<*>): Bson

Create a sort specification for a descending sort on the given properties.

Link copied to clipboard
fun descendingIndex(properties: Iterable<KProperty<*>>): Bson
fun descendingIndex(vararg properties: KProperty<*>): Bson

Create an index key for a descending index on the given fields.

Link copied to clipboard
operator fun <T0, T1, T2> KProperty1<T0, T1?>.div(p2: KProperty1<T1, T2?>): KProperty1<T0, T2?>

Returns a composed property. For example Friend.address / Address.postalCode = "address.postalCode".

@JvmName(name = "divCol")
operator fun <T0, T1, T2> KProperty1<T0, Iterable<T1>?>.div(p2: KProperty1<out T1, T2?>): KProperty1<T0, T2?>

Returns a collection composed property. For example Friend.addresses / Address.postalCode = "addresses.postalCode".

@JvmName(name = "divMap")
operator fun <T0, K, T1, T2> KProperty1<T0, Map<out K, T1>?>.div(p2: KProperty1<out T1, T2?>): KProperty1<T0, T2?>

Returns a map composed property. For example Friend.addresses / Address.postalCode = "addresses.postalCode".

Link copied to clipboard
fun document(elements: Collection<Bson>): Bson
fun document(vararg elements: Bson?): Bson

Produce a bson document with the specified elements.

Link copied to clipboard
infix fun <T> KProperty<Iterable<T>?>.elemMatch(filter: Bson): Bson

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.

Link copied to clipboard
fun <T> KProperty<T>.elemMatchProj(): Bson

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(filter: Bson): 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.

Link copied to clipboard
infix fun <T> KProperty<T?>.eq(value: T?): Bson

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.

Link copied to clipboard
fun exclude(properties: Iterable<KProperty<*>>): Bson
fun exclude(vararg properties: KProperty<*>): Bson

Creates a projection that excludes all of the given properties.

Link copied to clipboard
fun excludeId(): Bson

Creates a projection that excludes the _id field. This suppresses the automatic inclusion of _id that is the default, even when other fields are explicitly included.

Link copied to clipboard
fun <T> KProperty<T>.exists(): Bson

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

infix fun <T> KProperty<T>.exists(exists: Boolean): 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.

Link copied to clipboard
fun <TExpression> expr(expression: TExpression): Bson

Creates a filter that matches all documents that validate against the given JSON schema document.

Link copied to clipboard
fun facet(facets: List<Facet>): Bson
fun facet(vararg facets: Facet): Bson

Creates a facet pipeline stage

Link copied to clipboard
fun fields(projections: List<Bson>): Bson
fun fields(vararg projections: Bson): Bson

Creates a projection that combines the list of projections into a single one. If there are duplicate keys, the last one takes precedence.

Link copied to clipboard
Link copied to clipboard
fun findOneAndUpdateUpsert(): FindOneAndUpdateOptions

Creates an FindOneAndUpdateOptions and set upsert to true.

Link copied to clipboard
fun <T> Document.findValue(path: String): T?
fun <T> Document.findValue(property: KProperty<T?>): T?

Find the value for the specified path from the document.

Link copied to clipboard
infix fun <T> KProperty<T>.first(expression: T): BsonField

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

Link copied to clipboard

Format this string to remove space(s) between $ and next char

Link copied to clipboard
infix fun String.from(expression: Any): Bson

Builds Bson from this String format and the specified expression.

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

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

infix fun MongoOperator.from(expression: Any): Bson

Builds Bson for the MongoOperator and the specified expression.

Link copied to clipboard
fun geo2dsphere(properties: Iterable<KProperty<*>>): Bson
fun geo2dsphere(vararg properties: KProperty<*>): Bson

Create an index key for an 2dsphere index on the given fields.

Link copied to clipboard
infix fun <T> KProperty<T>.geoIntersects(geometry: Geometry): Bson
infix fun <T> KProperty<T>.geoIntersects(geometry: Bson): Bson

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

Link copied to clipboard
infix fun <T> KProperty<T>.geoWithin(geometry: Geometry): Bson
infix fun <T> KProperty<T>.geoWithin(geometry: Bson): Bson

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

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

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

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

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

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

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.

Link copied to clipboard
infix fun <T> KProperty<T>.geoWithinPolygon(points: List<List<Double>>): Bson

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

Link copied to clipboard
fun <TExpression> graphLookup(from: String, startWith: TExpression, connectFromField: String, connectToField: String, fieldAs: String, options: GraphLookupOptions = GraphLookupOptions()): Bson

Creates a graphLookup pipeline stage for the specified filter

Link copied to clipboard
fun <TExpression> group(id: TExpression, fieldAccumulators: List<BsonField>): Bson
fun <TExpression> group(id: TExpression, vararg fieldAccumulators: BsonField): Bson

Creates a $group pipeline stage for the specified filter

Link copied to clipboard
infix fun <T> KProperty<T?>.gt(value: T): Bson

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

Link copied to clipboard
infix fun <T> KProperty<T?>.gte(value: T): Bson

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

Link copied to clipboard
fun <T> KProperty<T>.hashedIndex(): Bson

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

Link copied to clipboard
fun hour(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "hourObjectId")
fun hour(property: KProperty<ObjectId?>): Bson

Builds $hour expression for this property .

Link copied to clipboard
fun ifNull(expression: Any, defaultValue: Any): Bson

$ifNull aggregator operator support.

Link copied to clipboard
fun KProperty<*>.ifNull(defaultValue: Any): Bson

$ifNull aggregator operator support.

Link copied to clipboard
infix fun <T> KProperty<T?>.in(values: Iterable<T?>): Bson
infix fun <T> KProperty<T>.in(expression: String): Bson
@JvmName(name = "inArray")
infix fun <T> KProperty<Iterable<T>?>.in(values: Iterable<T?>): Bson

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

Link copied to clipboard
fun <T : Number?> inc(property: KProperty<T>, number: Number): Bson
@JvmName(name = "ubyteinc")
fun inc(property: KProperty<UByte>, number: Number): Bson
@JvmName(name = "uintinc")
fun inc(property: KProperty<UInt>, number: Number): Bson
@JvmName(name = "ulonginc")
fun inc(property: KProperty<ULong>, number: Number): Bson
@JvmName(name = "ushortinc")
fun inc(property: KProperty<UShort>, number: Number): Bson

Creates an update that increments the value of the property by the given value.

Link copied to clipboard
fun include(properties: Iterable<KProperty<*>>): Bson

Creates a projection that includes all of the given properties.

fun include(vararg properties: KProperty<*>): Bson

Creates a projection that includes all given properties.

Link copied to clipboard
fun index(properties: Map<KProperty<*>, Boolean>): Bson

Create a compound multiple index specifications. If any properties are repeated, the last one takes precedence.

fun index(vararg properties: Pair<KProperty<*>, Boolean>): Bson

Create a compound index specifications. If any properties are repeated, the last one takes precedence.

Link copied to clipboard
fun IndexModel.IndexModel(keys: String, options: IndexOptions = IndexOptions()): IndexModel

Construct an instance with the given keys and options.

Link copied to clipboard
fun <T> insertOne(document: T): InsertOneModel<T>

Creates an InsertOneModel.

Link copied to clipboard
fun jsonSchema(schema: Bson): Bson

Creates a filter that matches all documents that validate against the given JSON schema document.

Link copied to clipboard
fun <K, T> KProperty1<out Any?, Map<out K, T>?>.keyProjection(key: K): KPropertyPath<Any?, T?>

Key projection of map. Sample: p.keyProjection(Locale.ENGLISH) / Gift::amount

Link copied to clipboard
infix fun <T> KProperty<T>.last(expression: T): BsonField

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

Link copied to clipboard
fun limit(limit: Int): Bson

Creates a $limit pipeline stage for the specified filter

Link copied to clipboard
fun lookup(from: String, localField: String, foreignField: String, newAs: String): Bson

Creates a $lookup pipeline stage for the specified filter

fun lookup(from: String, let: List<Variable<out Any>>? = null, resultProperty: KProperty<Any?>, vararg pipeline: Bson): Bson

Creates a $lookup pipeline stage, joining the current collection with the one specified in from using the given pipeline

Link copied to clipboard
infix fun <T> KProperty<T?>.lt(item: T): Bson

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

Link copied to clipboard
infix fun <T> KProperty<T?>.lte(value: T): Bson

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

Link copied to clipboard
fun match(filter: Bson): Bson

Creates a $match pipeline stage for the specified filter

fun match(vararg filters: Bson): Bson

Creates a

$match pipeline stage with $

and on each filter.

Link copied to clipboard
fun <T> max(property: KProperty<T>, value: T): Bson

Creates an update that sets the value of the property if the given value is greater than the current value of the property.

Link copied to clipboard
infix fun <T> KProperty<T>.max(expression: T): BsonField

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.

Link copied to clipboard
fun <T> KProperty<T>.metaTextScore(): Bson

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

Link copied to clipboard
fun millisecond(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "millisecondObjectId")
fun millisecond(property: KProperty<ObjectId?>): Bson

Builds $millisecond expression for this property .

Link copied to clipboard
fun <T> min(property: KProperty<T>, value: T): Bson

Creates an update that sets the value of the property if the given value is less than the current value of the property.

Link copied to clipboard
infix fun <T> KProperty<T>.min(expression: T): BsonField

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.

Link copied to clipboard
fun minute(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "minuteObjectId")
fun minute(property: KProperty<ObjectId?>): Bson

Builds $minute expression for this property .

Link copied to clipboard
fun <T> KProperty<T>.mod(divisor: Long, remainder: Long): Bson

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).

Link copied to clipboard
fun month(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "monthObjectId")
fun month(property: KProperty<ObjectId?>): Bson

Builds $month expression for this property .

Link copied to clipboard
fun <T : Number?> mul(property: KProperty<T>, number: Number): Bson
@JvmName(name = "ubytemul")
fun mul(property: KProperty<UByte>, number: Number): Bson
@JvmName(name = "uintmul")
fun mul(property: KProperty<UInt>, number: Number): Bson
@JvmName(name = "ulongmul")
fun mul(property: KProperty<ULong>, number: Number): Bson
@JvmName(name = "ushortmul")
fun mul(property: KProperty<UShort>, number: Number): Bson

Creates an update that multiplies the value of the property by the given number.

Link copied to clipboard
infix fun <T> KProperty<T?>.ne(value: T?): Bson

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

Link copied to clipboard
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 GeoJSON point.

fun <T> KProperty<T>.near(x: Double, y: Double, 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.

Link copied to clipboard
fun <T> KProperty<T>.nearSphere(geometry: Point, maxDistance: Double? = null, minDistance: Double? = null): Bson
fun <T> KProperty<T>.nearSphere(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 GeoJSON point using spherical geometry.

fun <T> KProperty<T>.nearSphere(x: Double, y: Double, 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.

Link copied to clipboard
infix fun <T> KProperty<T?>.nin(values: Iterable<T?>): Bson
@JvmName(name = "ninArray")
infix fun <T> KProperty<Iterable<T>?>.nin(values: Iterable<T?>): Bson

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.

Link copied to clipboard
fun nor(filters: Iterable<Bson>): Bson
fun nor(vararg filters: Bson): Bson

Creates a filter that performs a logical NOR operation on all the specified filters.

Link copied to clipboard
fun not(filter: Bson): Bson

Creates a filter that matches all documents that do not match the passed in filter. Requires the field name to passed as part of the value passed in and lifts it to create a valid "$not" query:

Link copied to clipboard
fun or(filters: Iterable<Bson?>): Bson
fun or(vararg filters: Bson?): Bson

Creates a filter that preforms a logical OR of the provided list of filters.

Link copied to clipboard
fun orderBy(sorts: Map<out KProperty<Any?>, Boolean>): Bson
fun orderBy(sorts: List<KProperty<*>>, ascending: Boolean = true): Bson
fun orderBy(vararg sorts: KProperty<*>, ascending: Boolean = true): Bson

Combine multiple sort specifications. If any properties are repeated, the last one takes precedence.

Link copied to clipboard
fun out(collectionName: String): Bson

Creates a $out pipeline stage for the specified filter

Link copied to clipboard
fun <T> KProperty<T>.path(): String

Returns a mongo path of a property.

Link copied to clipboard
fun <T> popFirst(property: KProperty<T>): Bson

Creates an update that pops the first element of an array that is the value of the property.

Link copied to clipboard
fun <T> popLast(property: KProperty<T>): Bson

Creates an update that pops the last element of an array that is the value of the property.

Link copied to clipboard
fun <T> KProperty1<out Any?, Iterable<T>?>.pos(position: Int): KPropertyPath<out Any?, T?>

In order to write array indexed expressions (like accesses.0.timestamp).

Link copied to clipboard
fun project(properties: Map<out KProperty<*>, Any?>): Bson
fun project(vararg properties: Pair<KProperty<*>, Any?>): Bson
fun project(vararg properties: KProperty<*>): Bson
fun project(vararg projections: Bson): Bson

Creates a $project pipeline stage for all specified properties

fun project(projection: Bson): Bson

Creates a $project pipeline stage for the specified getProjection

Link copied to clipboard

In order to write $p.p2

Link copied to clipboard
fun <T> pull(property: KProperty<Iterable<T?>?>, value: T?): Bson

Creates an update that removes all instances of the given value from the array value of the property.

Link copied to clipboard
fun <T> pullAll(property: KProperty<Iterable<T>?>, values: List<T?>?): Bson

Creates an update that removes all instances of the given values from the array value of the property.

Link copied to clipboard
fun pullByFilter(filter: Bson): Bson

Creates an update that removes from an array all elements that match the given filter.

fun pullByFilter(property: KProperty<*>, filter: Bson): Bson

Creates an update that removes all instances of the given value from the array value of the property.

Link copied to clipboard
fun <T> push(property: KProperty<Iterable<T>?>, value: T): Bson

Creates an update that adds the given value to the array value of the property.

Link copied to clipboard
infix fun <T> KProperty<T>.push(expression: T): BsonField

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.

Link copied to clipboard
fun <T> pushEach(property: KProperty<Iterable<T>?>, values: List<T?>, options: PushOptions = PushOptions()): Bson

Creates an update that adds each of the given values to the array value of the property, applying the given options for positioning the pushed values, and then slicing and/or sorting the array.

Link copied to clipboard
infix fun KProperty<String?>.regex(regex: Pattern): Bson
infix fun KProperty<String?>.regex(regex: String): Bson
infix fun KProperty<String?>.regex(regex: Regex): Bson
@JvmName(name = "regexIterable")
infix fun KProperty<Iterable<String?>>.regex(regex: Pattern): Bson
@JvmName(name = "regexIterable")
infix fun KProperty<Iterable<String?>>.regex(regex: String): Bson
@JvmName(name = "regexIterable")
infix fun KProperty<Iterable<String?>>.regex(regex: Regex): Bson

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

fun KProperty<String?>.regex(pattern: String, options: String): Bson
@JvmName(name = "regexIterable")
fun KProperty<Iterable<String?>>.regex(pattern: String, options: String): 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.

Link copied to clipboard
operator fun <T0, T1, T2> KProperty1<T0, T1?>.rem(p2: KProperty1<out T1, T2?>): KProperty1<T0, T2?>

Returns a composed property without type checks. For example Friend.address % Address.postalCode = "address.postalCode".

Link copied to clipboard
fun <T> rename(property: KProperty<T?>, newProperty: KProperty<T>): Bson

Creates an update that renames a field.

Link copied to clipboard
fun <T> replaceOne(filter: Bson, replacement: T, options: ReplaceOptions = ReplaceOptions()): ReplaceOneModel<T>

Creates an ReplaceOneModel.

Link copied to clipboard
fun <TExpression> replaceRoot(value: TExpression): Bson

Creates a $replaceRoot pipeline stage

Link copied to clipboard
fun replaceUpsert(): ReplaceOptions

Creates an ReplaceOptions and set upsert to true.

Link copied to clipboard
fun sample(size: Int): Bson

Creates a $sample pipeline stage with the specified sample size

Link copied to clipboard
fun second(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "secondObjectId")
fun second(property: KProperty<ObjectId?>): Bson

Builds $second expression for this property .

Link copied to clipboard
fun set(vararg properties: SetTo<*>): Bson

Creates an update that sets the values of the properties to the specified values.

Link copied to clipboard
fun <T> setOnInsert(property: KProperty<T?>, value: T): Bson

Creates an update that sets the value of the property to the given value, but only if the update is an upsert that results in an insert of a document.

Link copied to clipboard
infix fun <T> KProperty<T>.setTo(value: T): SetTo<T>

Generates a SetTo used in updateOne or updateMany operations.

Link copied to clipboard
fun <T> setValue(property: KProperty<T?>, value: T?): Bson

Creates an update that sets the value of the property to the given value.

Link copied to clipboard
fun setValueOnInsert(value: Any): Bson

Creates an update that sets the collection to the given value, but only if the update is an upsert that results in an insert of a document.

Link copied to clipboard
infix fun <T> KProperty<T>.size(size: Int): Bson

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

Link copied to clipboard
fun skip(skip: Int): Bson

Creates a $skip pipeline stage

Link copied to clipboard
fun <T> KProperty<T>.slice(limit: Int): Bson
fun <T> KProperty<T>.slice(skip: Int, limit: Int): Bson

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

Link copied to clipboard
fun sort(sort: Bson): Bson

Creates a $sort pipeline stage for the specified sort specification

Link copied to clipboard
fun <TExpression> sortByCount(filter: TExpression): Bson

Creates a $sortByCount pipeline stage for the specified filter

Link copied to clipboard

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

Link copied to clipboard
infix fun <T> KProperty<T>.stdDevPop(expression: T): BsonField

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.

Link copied to clipboard
infix fun <T> KProperty<T>.stdDevSamp(expression: T): BsonField

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.

Link copied to clipboard
infix fun <T> KProperty<T>.sum(expression: T): BsonField

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.

Link copied to clipboard
fun text(search: String, textSearchOptions: TextSearchOptions = TextSearchOptions()): Bson

Creates a filter that matches all documents matching the given the search term with the given text search options.

Link copied to clipboard
fun <T> KProperty<T>.textIndex(): Bson

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

Link copied to clipboard
infix fun <T> KProperty<T>.type(type: BsonType): Bson

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

Link copied to clipboard
fun <T> unset(property: KProperty<T>): Bson

Creates an update that deletes the property with the given name.

Link copied to clipboard
fun unwind(fieldName: String, unwindOptions: UnwindOptions = UnwindOptions()): Bson

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

Link copied to clipboard
fun <T> KProperty<T>.unwind(unwindOptions: UnwindOptions = UnwindOptions()): Bson

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

Link copied to clipboard
fun <T> updateMany(filter: Bson, update: Bson, options: UpdateOptions = UpdateOptions()): UpdateManyModel<T>

Creates an UpdateManyModel.

Link copied to clipboard
fun <T> updateOne(filter: Bson, update: Bson, options: UpdateOptions = UpdateOptions()): UpdateOneModel<T>

Creates an UpdateOneModel.

Link copied to clipboard
fun upsert(): UpdateOptions

Creates an UpdateOptions and set upsert to true.

Link copied to clipboard
fun KProperty<*>.variableDefinition(name: String = path()): Variable<String>

Defines a Variable for the lookup operator.

Link copied to clipboard
fun week(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "weekObjectId")
fun week(property: KProperty<ObjectId?>): Bson

Builds $week expression for this property .

Link copied to clipboard
fun where(javaScriptExpression: String): Bson

Creates a filter that matches all documents for which the given expression is true.

Link copied to clipboard
fun year(property: KProperty<TemporalAccessor?>): Bson
@JvmName(name = "yearObjectId")
fun year(property: KProperty<ObjectId?>): Bson

Builds $year expression for this property .