DateTimeValueOperators¶
interface DateTimeValueOperators : ValueOperators
Operators to manage date and time values.
To learn more about aggregation operators, view AggregationOperators.
Inheritors¶
Properties¶
context¶
@LowLevelApi
abstract override val context: BsonContext
The strategy used when converting from KProperty1 to Field.
dayOfMonth¶
open val <R : Any> KProperty1<R, Instant>.dayOfMonth: Value<R, Int>
open val Instant.dayOfMonth: Value<Any, Int>
@get:JvmName(name = "dayOfMonthOfObjectId")
val <R : Any> Value<R, ObjectId>.dayOfMonth: Value<R, Int>
@get:JvmName(name = "dayOfMonthOfObjectId")
val <R : Any> Field<R, ObjectId>.dayOfMonth: Value<R, Int>
@get:JvmName(name = "dayOfMonthOfObjectId")
val <R : Any> KProperty1<R, ObjectId>.dayOfMonth: Value<R, Int>
@get:JvmName(name = "dayOfMonthOfTimestamp")
val <R : Any> Value<R, Timestamp>.dayOfMonth: Value<R, Int>
@get:JvmName(name = "dayOfMonthOfTimestamp")
val <R : Any> Field<R, Timestamp>.dayOfMonth: Value<R, Int>
@get:JvmName(name = "dayOfMonthOfTimestamp")
val <R : Any> KProperty1<R, Timestamp>.dayOfMonth: Value<R, Int>
Returns the day of the month for a date as a number between 1 and 31.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthdayOfMonth: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthdayOfMonth set User::birthdate.dayOfMonth
}
}
External resources
dayOfWeekISO¶
open val <R : Any> KProperty1<R, Instant>.dayOfWeekISO: Value<R, Int>
open val Instant.dayOfWeekISO: Value<Any, Int>
@get:JvmName(name = "dayOfWeekISOOfObjectId")
val <R : Any> Value<R, ObjectId>.dayOfWeekISO: Value<R, Int>
@get:JvmName(name = "dayOfWeekISOOfObjectId")
val <R : Any> Field<R, ObjectId>.dayOfWeekISO: Value<R, Int>
@get:JvmName(name = "dayOfWeekISOOfObjectId")
val <R : Any> KProperty1<R, ObjectId>.dayOfWeekISO: Value<R, Int>
@get:JvmName(name = "dayOfWeekISOOfTimestamp")
val <R : Any> Value<R, Timestamp>.dayOfWeekISO: Value<R, Int>
@get:JvmName(name = "dayOfWeekISOOfTimestamp")
val <R : Any> Field<R, Timestamp>.dayOfWeekISO: Value<R, Int>
@get:JvmName(name = "dayOfWeekISOOfTimestamp")
val <R : Any> KProperty1<R, Timestamp>.dayOfWeekISO: Value<R, Int>
Returns the day of the week in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday).
To get the current week number, see weekISO.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthdayOfWeekISO: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO
}
}
External resources
dayOfWeekUS¶
open val <R : Any> KProperty1<R, Instant>.dayOfWeekUS: Value<R, Int>
open val Instant.dayOfWeekUS: Value<Any, Int>
@get:JvmName(name = "dayOfWeekUSOfObjectId")
val <R : Any> Value<R, ObjectId>.dayOfWeekUS: Value<R, Int>
@get:JvmName(name = "dayOfWeekUSOfObjectId")
val <R : Any> Field<R, ObjectId>.dayOfWeekUS: Value<R, Int>
@get:JvmName(name = "dayOfWeekUSOfObjectId")
val <R : Any> KProperty1<R, ObjectId>.dayOfWeekUS: Value<R, Int>
@get:JvmName(name = "dayOfWeekUSOfTimestamp")
val <R : Any> Value<R, Timestamp>.dayOfWeekUS: Value<R, Int>
@get:JvmName(name = "dayOfWeekUSOfTimestamp")
val <R : Any> Field<R, Timestamp>.dayOfWeekUS: Value<R, Int>
@get:JvmName(name = "dayOfWeekUSOfTimestamp")
val <R : Any> KProperty1<R, Timestamp>.dayOfWeekUS: Value<R, Int>
Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).
To use ISO 8601 day-of-week numbering (1 for Monday to 7 for Sunday), see dayOfWeekISO.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthdayOfWeekUS: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS
}
}
External resources
dayOfYear¶
@get:JvmName(name = "dayOfYearOfObjectId")
val <R : Any> Value<R, ObjectId>.dayOfYear: Value<R, Int>
@get:JvmName(name = "dayOfYearOfObjectId")
val <R : Any> Field<R, ObjectId>.dayOfYear: Value<R, Int>
@get:JvmName(name = "dayOfYearOfObjectId")
val <R : Any> KProperty1<R, ObjectId>.dayOfYear: Value<R, Int>
@get:JvmName(name = "dayOfYearOfTimestamp")
val <R : Any> Value<R, Timestamp>.dayOfYear: Value<R, Int>
@get:JvmName(name = "dayOfYearOfTimestamp")
val <R : Any> Field<R, Timestamp>.dayOfYear: Value<R, Int>
Returns the day of the year for a date as a number between 1 and 366.
The year starts on January 1st, so January 1st is day 1, and December 31st is day 365 (or 366 in a leap year).
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthdayOfYear: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthdayOfYear set User::birthdate.dayOfYear
}
}
External resources
field¶
Converts a Kotlin property into a Field.
hour¶
Returns the hour portion of a date as a number between 0 and 23.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthhour: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthhour set User::birthdate.hour
}
}
External resources
millisecond¶
open val <R : Any> KProperty1<R, Instant>.millisecond: Value<R, Int>
open val Instant.millisecond: Value<Any, Int>
@get:JvmName(name = "millisecondOfObjectId")
val <R : Any> Value<R, ObjectId>.millisecond: Value<R, Int>
@get:JvmName(name = "millisecondOfObjectId")
val <R : Any> Field<R, ObjectId>.millisecond: Value<R, Int>
@get:JvmName(name = "millisecondOfObjectId")
val <R : Any> KProperty1<R, ObjectId>.millisecond: Value<R, Int>
@get:JvmName(name = "millisecondOfTimestamp")
val <R : Any> Value<R, Timestamp>.millisecond: Value<R, Int>
@get:JvmName(name = "millisecondOfTimestamp")
val <R : Any> Field<R, Timestamp>.millisecond: Value<R, Int>
@get:JvmName(name = "millisecondOfTimestamp")
val <R : Any> KProperty1<R, Timestamp>.millisecond: Value<R, Int>
Returns the millisecond portion of a date as a number between 0 and 999.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthmillisecond: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthmillisecond set User::birthdate.millisecond
}
}
External resources
minute¶
Returns the minute portion of a date as a number between 0 and 59.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthminute: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthminute set User::birthdate.minute
}
}
External resources
month¶
Returns the month of a date as a number between 1 and 12.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthmonth: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthmonth set User::birthdate.month
}
}
External resources
second¶
Returns the second portion of a date as a number between 0 and 60 (leap seconds).
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthsecond: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthsecond set User::birthdate.second
}
}
External resources
weekISO¶
@get:JvmName(name = "weekISOOfObjectId")
val <R : Any> KProperty1<R, ObjectId>.weekISO: Value<R, Int>
Returns the week number in ISO 8601 format, ranging from 1 to 53.
Week numbers start at 1 with the week (Monday through Sunday) that contains the year's first Thursday.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthweekISO: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthweekISO set User::birthdate.weekISO
}
}
External resources
weekUS¶
Returns the week of the year for a date, ranging from 0 to 53.
Weeks begin on Sundays, and week 1 begins with the first Sunday of the year. Days preceding the first Sunday of the year are in week 0.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthweekUS: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthweekUS set User::birthdate.weekUS
}
}
External resources
year¶
yearOfISOWeek¶
open val <R : Any> KProperty1<R, Instant>.yearOfISOWeek: Value<R, Int>
open val Instant.yearOfISOWeek: Value<Any, Int>
@get:JvmName(name = "yearOfISOWeekOfObjectId")
val <R : Any> Value<R, ObjectId>.yearOfISOWeek: Value<R, Int>
@get:JvmName(name = "yearOfISOWeekOfObjectId")
val <R : Any> Field<R, ObjectId>.yearOfISOWeek: Value<R, Int>
@get:JvmName(name = "yearOfISOWeekOfObjectId")
val <R : Any> KProperty1<R, ObjectId>.yearOfISOWeek: Value<R, Int>
@get:JvmName(name = "yearOfISOWeekOfTimestamp")
val <R : Any> Value<R, Timestamp>.yearOfISOWeek: Value<R, Int>
@get:JvmName(name = "yearOfISOWeekOfTimestamp")
val <R : Any> Field<R, Timestamp>.yearOfISOWeek: Value<R, Int>
@get:JvmName(name = "yearOfISOWeekOfTimestamp")
val <R : Any> KProperty1<R, Timestamp>.yearOfISOWeek: Value<R, Int>
Returns the year in ISO 8601 format, corresponding to the ISO week number returned by weekISO.
The year always starts on the first day of weekISO 1, which must be a Monday. This means that the year may start anywhere between January 1st and January 7th (if January 1st was a Tuesday). The year ends on the last synday of the last week, which may be at the start of January for the same reason.
The accepted date types are Instant, ObjectId and Timestamp.
Example
class User(
val name: String,
val birthdate: Instant,
val birthyearOfISOWeek: Int? = null,
)
users.updateManyWithPipeline {
set {
User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek
}
}
External resources
Functions¶
div¶
open operator fun <Context : Any, Root, Child> Value<Context, Root>.div(field: Field<Root, Child>): Value<Context, Child>
@JvmName(name = "divFieldReceiver")
open operator fun <Context : Any, Root, Child> Field<Context, Root>.div(field: Field<Root, Child>): Value<Context, Child>
@JvmName(name = "divResultReceiver")
inline operator fun <Context : Any, Root, Child> Root.div(field: Field<Root, Child>): Value<Context, Child>
open operator fun <Context : Any, Root, Child> Value<Context, Root>.div(field: KProperty1<Root, Child>): Value<Context, Child>
Refers to field as a nested field of the current value.
Examples
class User(
val name: String,
)
class Data(
val users: List<User>,
val userNames: List<Int>,
)
data.aggregate()
.set {
Data::userNames set Data::users.map { it / User::name }
}
External resources
get¶
Refers to a specific item in an array, by its index.
Refers to a specific item in a map, by its name.
Refers to a specific item in an array, by its index.
Refers to a specific item in a map, by its name.
of¶
Refers to a field within an aggregation value.
Example
Refers to a Kotlin value within an aggregation value.
Example
Refers to a BsonType within an aggregation value.
Example
unsafe¶
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>
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, without checking that it is a field available on the current object.
Refers to a field child of the current field, without checking that it is a field available on the current object.