Skip to content

MongoDB request DSLopensavvy.ktmongo.dsl.queryUpsertQuery

UpsertQuery

interface UpsertQuery<T> : UpdateQuery<T> 

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

all

open val <E> KProperty1<T, Collection<E>>.all: Field<T, E>

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

open val <E> Field<T, Collection<E>>.all: Field<T, E>

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

context

abstract val context: 

The context used to generate this expression.

field

Converts a Kotlin property into a Field.

selected

open val <E> KProperty1<T, Collection<E>>.selected: Field<T, E>

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

open val <E> Field<T, Collection<E>>.selected: Field<T, E>

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

Functions

accept

abstract override fun accept(node: BsonNode)

Adds a new node as a child of this one.

acceptAll

fun <N : Node> CompoundNode<N>.acceptAll(nodes: Iterable<N>)

Adds any number of nodes into this one.

addToSet

open infix fun <V> KProperty1<T, Collection<V>>.addToSet(value: V)

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

open infix fun <V> KProperty1<T, Collection<V>>.addToSet(values: Iterable<V>)

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

abstract infix fun <V> Field<T, Collection<V>>.addToSet(value: V)

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

open infix fun <V> Field<T, Collection<V>>.addToSet(values: Iterable<V>)

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

div

open operator fun <Root, Parent, Child> KProperty1<Root, Parent>.div(child: KProperty1<Parent & Any, Child>): Field<Root, Child>

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

freeze

abstract override fun freeze()

Makes this expression immutable.

get

open operator fun <Root, Type> KProperty1<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>

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

inc

open infix fun <V : Number> KProperty1<T, V>.inc(amount: V)

Increments a field by the specified amount.

abstract infix fun <V : Number> Field<T, V>.inc(amount: V)

Increments a field by the specified amount.

max

open infix fun <V : Comparable<V>> KProperty1<T, V?>.max(value: V)

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

abstract infix fun <V : Comparable<V>> Field<T, V?>.max(value: V)

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

min

open infix fun <V : Comparable<V>> KProperty1<T, V?>.min(value: V)

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

abstract infix fun <V : Comparable<V>> Field<T, V?>.min(value: V)

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

mul

open infix fun <V : Number> KProperty1<T, V>.mul(amount: V)

Multiplies a field by the specified amount.

abstract infix fun <V : Number> Field<T, V>.mul(amount: V)

Multiplies a field by the specified amount.

plusAssign

open operator fun <V : Number> KProperty1<T, V>.plusAssign(amount: V)

Increments a field by the specified amount.

open operator fun <V : Number> Field<T, V>.plusAssign(amount: V)

Increments a field by the specified amount.

renameTo

open infix fun <V> KProperty1<T, V>.renameTo(newName: KProperty1<T, V>)

Renames a field.

open infix fun <V> KProperty1<T, V>.renameTo(newName: Field<T, V>)

Renames a field.

open infix fun <V> Field<T, V>.renameTo(newName: KProperty1<T, V>)

Renames a field.

abstract infix fun <V> Field<T, V>.renameTo(newName: Field<T, V>)

Renames a field.

set

open infix fun <V> KProperty1<T, V>.set(value: V)

Replaces the value of a field with the specified value.

abstract infix fun <V> Field<T, V>.set(value: V)

Replaces the value of a field with the specified value.

setIf

open fun <V> KProperty1<T, V>.setIf(condition: Boolean, value: V)

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

open fun <V> Field<T, V>.setIf(condition: Boolean, value: V)

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

setOnInsert

open infix fun <V> KProperty1<T, V>.setOnInsert(value: V)

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.

abstract infix fun <V> Field<T, V>.setOnInsert(value: V)

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.

setToCurrentDate

open fun KProperty1<T, ?>.setToCurrentDate()

Sets this field to the current date.

open fun KProperty1<T, ?>.setToCurrentDate()

Sets this field to the current timestamp.

abstract fun Field<T, ?>.setToCurrentDate()

Sets this field to the current date.

abstract fun Field<T, ?>.setToCurrentDate()

Sets this field to the current timestamp.

setUnless

open fun <V> KProperty1<T, V>.setUnless(condition: Boolean, value: V)

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

open fun <V> Field<T, V>.setUnless(condition: Boolean, value: V)

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

simplify

abstract fun simplify(): BsonNode?

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

toBson

open fun toBson(): 

Writes the result of simplifying to a new Bson.

toString

abstract override fun toString(): String

JSON representation of this expression.

unset

open fun <V> KProperty1<T, V>.unset()

Deletes a field.

abstract fun <V> Field<T, V>.unset()

Deletes a field.

writeTo

abstract fun writeTo(writer: )

Writes the result of simplifying this expression into writer.