UpsertQuery

interface UpsertQuery<T> : UpdateQuery<T> (source)

DSL for MongoDB operators that are used to update existing values, creating new documents if none exist (does not include aggregation operators).

This interface is a variant of UpdateQuery used in upsert operations. See UpdateQuery for more information.

If you can't find the operator you're searching for, visit the tracking issue.

Properties

Link copied to clipboard
open val <E> KProperty1<T, Collection<E>>.all: Field<T, E>
open val <E> Field<T, Collection<E>>.all: Field<T, E>

The all positional operator: selects all elements of an array.

Link copied to clipboard

The context used to generate this expression.

Link copied to clipboard

Converts a Kotlin property into a Field.

Link copied to clipboard
open val <E> Field<T, Collection<E>>.selected: Field<T, E>

The positional operator: update an array item selected in the filter.

Functions

Link copied to clipboard
abstract override fun accept(node: BsonNode)

Adds a new node as a child of this one.

Link copied to clipboard

Adds any number of nodes into this one.

Link copied to clipboard
infix inline fun <V> KProperty1<T, Collection<V>>.addEachToSet(values: Iterable<V>)
infix inline fun <V> Field<T, Collection<V>>.addEachToSet(values: Iterable<V>)
open fun <V> Field<T, Collection<V>>.addEachToSet(values: Iterable<V>, type: KType)

Adds multiple values at the end of the array, unless they are already present.

Link copied to clipboard
infix inline fun <V> KProperty1<T, Collection<V>>.addToSet(value: V)
infix inline fun <V> Field<T, Collection<V>>.addToSet(value: V)
abstract fun <V> Field<T, Collection<V>>.addToSet(value: V, type: KType)

Adds value at the end of the array, unless it is already present, in which case it does nothing.

Link copied to clipboard
open infix fun KProperty1<T, Int>.bitAnd(mask: Int)
open infix fun KProperty1<T, Long>.bitAnd(mask: Long)
abstract infix fun Field<T, Int>.bitAnd(mask: Int)
abstract infix fun Field<T, Long>.bitAnd(mask: Long)

Performs a bitwise AND operation on a field.

Link copied to clipboard
open infix fun KProperty1<T, Int>.bitOr(mask: Int)
open infix fun KProperty1<T, Long>.bitOr(mask: Long)
abstract infix fun Field<T, Int>.bitOr(mask: Int)
abstract infix fun Field<T, Long>.bitOr(mask: Long)

Performs a bitwise OR operation on a field.

Link copied to clipboard
open infix fun KProperty1<T, Int>.bitXor(mask: Int)
open infix fun KProperty1<T, Long>.bitXor(mask: Long)
abstract infix fun Field<T, Int>.bitXor(mask: Int)
abstract infix fun Field<T, Long>.bitXor(mask: Long)

Performs a bitwise XOR (exclusive OR) operation on a field.

Link copied to clipboard
open operator fun <Root, Parent, Child> KProperty1<Root, Parent>.div(child: KProperty1<Parent & Any, Child>): Field<Root, Child>
open operator fun <Root, Type, Child> Field<Root, Type>.div(child: KProperty1<in Type & Any, Child>): Field<Root, Child>
open operator fun <Root, Type, Child> Field<Root, Type>.div(child: Field<Type, Child>): Field<Root, Child>

Refers to child as a nested field of the current field.

Link copied to clipboard
abstract fun <V> Field<T, Collection<V>>.filter(id: String): Field<T, V>
abstract fun <V> Field<T, Collection<V>>.filter(id: String? = null, filter: ArrayFiltersOptionDsl<V>.(it: Field<ArrayFiltersOptionDsl.IteratorType<V>, V>) -> Unit): Field<T, V>

Filters an array and performs the specified update only on the filtered items.

Link copied to clipboard
abstract override fun freeze()

Makes this expression immutable.

Link copied to clipboard
open operator fun <Root, Type> KProperty1<Root, Collection<Type>>.get(index: Int): Field<Root, Type>
open operator fun <Root, Type> Field<Root, Collection<Type>>.get(index: Int): Field<Root, Type>

Refers to a specific item in an array, by its index.

open operator fun <Root, Type> KProperty1<Root, Map<String, Type>>.get(index: String): Field<Root, Type>
open operator fun <Root, Type> Field<Root, Map<String, Type>>.get(key: String): Field<Root, Type>

Refers to a specific item in a map, by its name.

Link copied to clipboard
infix inline fun <V : Number> KProperty1<T, V>.inc(amount: V)
infix inline fun <V : Number> Field<T, V>.inc(amount: V)
abstract fun <V : Number> Field<T, V>.inc(amount: V, type: KType)

Increments a field by the specified amount.

Link copied to clipboard
infix inline fun <V : Comparable<V>> KProperty1<T, V?>.max(value: V)
infix inline fun <V : Comparable<V>> Field<T, V?>.max(value: V)
abstract fun <V : Comparable<V>> Field<T, V?>.max(value: V, type: KType)

Updates the value of a field to the specified value only if the specified value is greater than the current value of the field.

Link copied to clipboard
infix inline fun <V : Comparable<V>> KProperty1<T, V?>.min(value: V)
infix inline fun <V : Comparable<V>> Field<T, V?>.min(value: V)
abstract fun <V : Comparable<V>> Field<T, V?>.min(value: V, type: KType)

Updates the value of a field to the specified value only if the specified value is less than the current value of the field.

Link copied to clipboard
infix inline fun <V : Number> KProperty1<T, V>.mul(amount: V)
infix inline fun <V : Number> Field<T, V>.mul(amount: V)
abstract fun <V : Number> Field<T, V>.mul(amount: V, type: KType)

Multiplies a field by the specified amount.

Link copied to clipboard
inline operator fun <V : Number> KProperty1<T, V>.plusAssign(amount: V)
inline operator fun <V : Number> Field<T, V>.plusAssign(amount: V)

Increments a field by the specified amount.

Link copied to clipboard
abstract fun Field<T, Collection<*>>.popFirst()

Removes the first element in the specified array.

Link copied to clipboard
open fun KProperty1<T, Collection<*>>.popLast()
abstract fun Field<T, Collection<*>>.popLast()

Removes the last element in the specified array.

Link copied to clipboard
infix inline fun <V> KProperty1<T, Collection<V>>.pull(value: V)
infix inline fun <V> Field<T, Collection<V>>.pull(value: V)
abstract fun <V> Field<T, Collection<V>>.pull(value: V, type: KType)

Removes all instances of value from the specified array.

infix inline fun <V> KProperty1<T, Collection<V>>.pull(noinline predicate: FilterQuery<V>.() -> Unit)
infix inline fun <V> Field<T, Collection<V>>.pull(noinline predicate: FilterQuery<V>.() -> Unit)
abstract fun <V> Field<T, Collection<V>>.pull(predicate: FilterQuery<V>.() -> Unit, type: KType)

Removes all items of an array that match predicate.

Link copied to clipboard
infix inline fun <V> KProperty1<T, Collection<V>>.pullValues(noinline predicate: FilterQueryPredicate<V>.() -> Unit)
infix inline fun <V> Field<T, Collection<V>>.pullValues(noinline predicate: FilterQueryPredicate<V>.() -> Unit)
abstract fun <V> Field<T, Collection<V>>.pullValues(predicate: FilterQueryPredicate<V>.() -> Unit, type: KType)

Removes all items of an array that match predicate.

Link copied to clipboard
infix inline fun <V> KProperty1<T, Collection<V>>.push(value: V)
infix inline fun <V> Field<T, Collection<V>>.push(value: V)
abstract fun <V> Field<T, Collection<V>>.push(value: V, type: KType)

Adds value at the end of the array.

infix inline fun <V> KProperty1<T, Collection<V>>.push(noinline builder: UpdateQuery.PushBuilder<V>.() -> Unit)
infix inline fun <V> Field<T, Collection<V>>.push(noinline builder: UpdateQuery.PushBuilder<V>.() -> Unit)
abstract fun <V> Field<T, Collection<V>>.push(builder: UpdateQuery.PushBuilder<V>.() -> Unit, type: KType)

Adds values to the end of the array with advanced options.

Link copied to clipboard
infix inline fun <V> KProperty1<T, Collection<V>>.pushEach(values: Iterable<V>)
infix inline fun <V> Field<T, Collection<V>>.pushEach(values: Iterable<V>)
open fun <V> Field<T, Collection<V>>.pushEach(values: Iterable<V>, type: KType)

Adds multiple values at the end of the array.

Link copied to clipboard
open infix fun <V> KProperty1<T, V>.renameTo(newName: KProperty1<T, V>)
open infix fun <V> KProperty1<T, V>.renameTo(newName: Field<T, V>)
open infix fun <V> Field<T, V>.renameTo(newName: KProperty1<T, V>)
abstract infix fun <V> Field<T, V>.renameTo(newName: Field<T, V>)

Renames a field.

Link copied to clipboard
infix inline fun <V> KProperty1<T, V>.set(value: V)
infix inline fun <V> Field<T, V>.set(value: V)
abstract fun <V> Field<T, V>.set(value: V, type: KType)

Replaces the value of a field with the specified value.

Link copied to clipboard
inline fun <V> KProperty1<T, V>.setIf(condition: Boolean, value: V)
inline fun <V> Field<T, V>.setIf(condition: Boolean, value: V)

Replaces the value of a field with the specified value, if condition is true.

Link copied to clipboard
infix inline fun <V> KProperty1<T, V>.setOnInsert(value: V)
infix inline fun <V> Field<T, V>.setOnInsert(value: V)
abstract fun <V> Field<T, V>.setOnInsert(value: V, type: KType)

If an upsert operation results in an insert of a document, then this operator assigns the specified value to the field. If the update operation does not result in an insert, this operator does nothing.

Link copied to clipboard
abstract fun Field<T, Instant?>.setToCurrentDate()

Sets this field to the current date.

@JvmName(name = "setToCurrentTimestamp")
open fun KProperty1<T, Timestamp?>.setToCurrentDate()
@JvmName(name = "setToCurrentTimestamp")
abstract fun Field<T, Timestamp?>.setToCurrentDate()

Sets this field to the current timestamp.

Link copied to clipboard
inline fun <V> KProperty1<T, V>.setUnless(condition: Boolean, value: V)
inline fun <V> Field<T, V>.setUnless(condition: Boolean, value: V)

Replaces the value of a field with the specified value, if condition is false.

Link copied to clipboard
abstract fun simplify(): BsonNode?

Returns a simplified (but equivalent) expression to the current expression.

Link copied to clipboard
inline operator fun <V : Number> KProperty1<T, V>.timesAssign(amount: V)
inline operator fun <V : Number> Field<T, V>.timesAssign(amount: V)

Multiplies a field by the specified amount.

Link copied to clipboard

Writes the result of simplifying to a new BsonDocument.

Link copied to clipboard
abstract override fun toString(): String

JSON representation of this expression.

Link copied to clipboard
open infix fun <Root, Child> KProperty1<Root, *>.unsafe(child: String): Field<Root, Child>
open infix fun <Root, Type, Child> Field<Root, Type>.unsafe(child: String): Field<Root, Child>

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>
open infix fun <Root, Child> KProperty1<Root, *>.unsafe(child: Field<*, Child>): Field<Root, Child>
open infix fun <Root, Child> Field<Root, *>.unsafe(child: KProperty1<*, Child>): Field<Root, Child>
open infix fun <Root, Child> Field<Root, *>.unsafe(child: Field<*, 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.

Link copied to clipboard
open fun <V> KProperty1<T, V>.unset()
abstract fun <V> Field<T, V>.unset()

Deletes a field.

Link copied to clipboard
abstract override fun writeTo(writer: BsonFieldWriter)

Writes the result of simplifying this expression into writer.