MongoDB request DSL • opensavvy.ktmongo.dsl.query • UpdateQuery
UpdateQuery¶
interface UpdateQuery<T> : CompoundBsonNode, FieldDsl
DSL for MongoDB operators that are used to update existing values (does not include aggregation operators).
Example¶
This expression type is available on multiple operations, most commonly update
:
class User(
val name: String,
val age: Int,
)
collection.update(
filter = {
User::name eq "Bob"
},
update = {
User::age set 18
}
)
Operators¶
On regular fields:
On arrays:
Time management:
If you can't find the operator you're searching for, visit the tracking issue.
External resources¶
See also¶
FilterQuery
Filters
Inheritors¶
Properties¶
all
¶
open val <E> KProperty1<T, Collection<E>>.all: Field<T, E>
The all positional operator: selects all elements of an array.
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.
The positional operator: update an array item selected in the filter.
Functions¶
accept
¶
Adds a new node
as a child of this one.
acceptAll
¶
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.
Adds value
at the end of the array, unless it is already present, in which case it does nothing.
Adds multiple values
at the end of the array, unless they are already present.
div
¶
Refers to child
as a nested field of the current field.
freeze
¶
abstract override fun freeze()
Makes this expression immutable.
get
¶
Refers to a specific item in an array, by its index.
Refers to a specific item in a map, by its name.
inc
¶
Increments a field by the specified amount
.
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.
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.
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
¶
Multiplies a field by the specified amount
.
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
.
Increments a field by the specified amount
.
renameTo
¶
open infix fun <V> KProperty1<T, V>.renameTo(newName: KProperty1<T, V>)
Renames a field.
Renames a field.
Renames a field.
Renames a field.
set
¶
Replaces the value of a field with the specified value
.
Replaces the value of a field with the specified value
.
setIf
¶
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
¶
simplify
¶
Returns a simplified (but equivalent) expression to the current expression.
toBson
¶
open fun toBson():
Writes the result of simplifying
to a new Bson.
toString
¶
JSON representation of this expression.
unset
¶
open fun <V> KProperty1<T, V>.unset()
Deletes a field.
Deletes a field.
writeTo
¶
abstract fun writeTo(writer: )
Writes the result of simplifying
this expression into writer
.