setToCurrentDate

Sets this field to the current date.

If the field does not exist, this operator adds the field to the document.

Example

class User(
val name: String?,
val age: Int,
val modificationDate: Instant,
)

collection.filter {
User::name eq "Bob"
}.updateMany {
User::age set 18
User::modificationDate.setToCurrentDate()
}

External resources


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

Sets this field to the current timestamp.

If the field does not exist, this operator adds the field to the document.

The time Timestamp is internal. Instant should be preferred. For more information, see Timestamp.

Example

class User(
val name: String?,
val age: Int,
val modificationDate: Timestamp,
)

collection.filter {
User::name eq "Bob"
}.updateMany {
User::age set 18
User::modificationDate.setToCurrentDate()
}

External resources