From 19a4acea78231037101faa5aa00ab1e84dfc169c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sat, 8 Aug 2026 12:04:09 +0200 Subject: [PATCH 01/14] feat(dsl): Add $year (aggregation) --- .../aggregation/AggregationOperators.kt | 4 + .../operators/DateTimeValueOperators.kt | 150 ++++++ .../aggregation/AggregationOperators.kt | 4 + .../operators/DateTimeValueOperators.kt | 430 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 49 ++ 5 files changed, 637 insertions(+) create mode 100644 dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt create mode 100644 dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt create mode 100644 dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 7810fe14..c215bbb4 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -136,6 +136,9 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toString`][TypeValueOperators.toText] * - [`$toUUID`][TypeValueOperators.toUuid] * + * Date and time operators: + * - [`$year`][DateTimeValueOperators.year] + * * Trigonometric operators and angle management: * - [`$acos`][TrigonometryValueOperators.acos] * - [`$acosh`][TrigonometryValueOperators.acosh] @@ -159,6 +162,7 @@ interface AggregationOperators : ValueOperators, ArrayValueOperators, ComparisonValueOperators, ConditionalValueOperators, + DateTimeValueOperators, ArithmeticValueOperators, StringValueOperators, TrigonometryValueOperators, diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt new file mode 100644 index 00000000..42d4cc2c --- /dev/null +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2026, OpenSavvy and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package opensavvy.ktmongo.dsl.aggregation.operators + +import opensavvy.ktmongo.bson.BsonValueWriter +import opensavvy.ktmongo.bson.types.ObjectId +import opensavvy.ktmongo.bson.types.Timestamp +import opensavvy.ktmongo.dsl.BsonContext +import opensavvy.ktmongo.dsl.KtMongoDsl +import opensavvy.ktmongo.dsl.LowLevelApi +import opensavvy.ktmongo.dsl.aggregation.AbstractValue +import opensavvy.ktmongo.dsl.aggregation.AggregationOperators +import opensavvy.ktmongo.dsl.aggregation.Value +import kotlin.jvm.JvmName +import kotlin.time.Instant + +/** + * Operators to manage date and time values. + * + * To learn more about aggregation operators, view [AggregationOperators]. + */ +@KtMongoDsl +interface DateTimeValueOperators : ValueOperators { + + // region $year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + val Value.year: Value + get() = UnaryOperator(context, "year", this) + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfObjectId") + final val Value.year: Value + get() = UnaryOperator(context, "year", this) + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfTimestamp") + final val Value.year: Value + get() = UnaryOperator(context, "year", this) + + // endregion + + @LowLevelApi + private class UnaryOperator( + context: BsonContext, + private val operator: String, + private val input: Value, + ) : AbstractValue(context) { + + @LowLevelApi + override fun write(writer: BsonValueWriter) = with(writer) { + writeDocument { + write("$$operator") { + input.writeTo(this) + } + } + } + } +} diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 03c982b7..aae5ba45 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -139,6 +139,9 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toString`][TypeValueOperators.toText] * - [`$toUUID`][TypeValueOperators.toUuid] * + * Date and time operators: + * - [`$year`][DateTimeValueOperators.year] + * * Trigonometric operators and angle management: * - [`$acos`][TrigonometryValueOperators.acos] * - [`$acosh`][TrigonometryValueOperators.acosh] @@ -162,6 +165,7 @@ interface AggregationOperators : ValueOperators, ArrayValueOperators, ComparisonValueOperators, ConditionalValueOperators, + DateTimeValueOperators, ArithmeticValueOperators, StringValueOperators, TrigonometryValueOperators, diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt new file mode 100644 index 00000000..8d426f48 --- /dev/null +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -0,0 +1,430 @@ +/* + * Copyright (c) 2026, OpenSavvy and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is generated from dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +// DO NOT EDIT THIS FILE DIRECTLY. To learn more, read dsl-template/README.md. + +package opensavvy.ktmongo.dsl.aggregation.operators + +import opensavvy.ktmongo.bson.BsonValueWriter +import opensavvy.ktmongo.bson.types.ObjectId +import opensavvy.ktmongo.bson.types.Timestamp +import opensavvy.ktmongo.dsl.BsonContext +import opensavvy.ktmongo.dsl.KtMongoDsl +import opensavvy.ktmongo.dsl.LowLevelApi +import opensavvy.ktmongo.dsl.aggregation.AbstractValue +import opensavvy.ktmongo.dsl.aggregation.AggregationOperators +import opensavvy.ktmongo.dsl.aggregation.Value +import kotlin.jvm.JvmName +import kotlin.time.Instant + +/** + * Operators to manage date and time values. + * + * To learn more about aggregation operators, view [AggregationOperators]. + */ +@KtMongoDsl +interface DateTimeValueOperators : ValueOperators { + + // region $year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + val Value.year: Value + get() = UnaryOperator(context, "year", this) + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.year: Value + get() = of(this).year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.year: Value + get() = of(this).year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.year: Value + get() = of(this).year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfObjectId") + final val Value.year: Value + get() = UnaryOperator(context, "year", this) + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.year: Value + get() = of(this).year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfObjectId") + final val kotlin.reflect.KProperty1.year: Value + get() = of(this).year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfObjectId") + final val ObjectId.year: Value + get() = of(this).year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfTimestamp") + final val Value.year: Value + get() = UnaryOperator(context, "year", this) + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.year: Value + get() = of(this).year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfTimestamp") + final val kotlin.reflect.KProperty1.year: Value + get() = of(this).year + + /** + * Returns the year portion of a date. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyear set User::birthdate.year + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/year/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfTimestamp") + final val Timestamp.year: Value + get() = of(this).year + + // endregion + + @LowLevelApi + private class UnaryOperator( + context: BsonContext, + private val operator: String, + private val input: Value, + ) : AbstractValue(context) { + + @LowLevelApi + override fun write(writer: BsonValueWriter) = with(writer) { + writeDocument { + write("$$operator") { + input.writeTo(this) + } + } + } + } +} diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt new file mode 100644 index 00000000..2a94ffac --- /dev/null +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2026, OpenSavvy and contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package opensavvy.ktmongo.dsl.aggregation.operators + +import opensavvy.ktmongo.dsl.aggregation.TestPipeline +import opensavvy.ktmongo.dsl.aggregation.shouldBeBson +import opensavvy.ktmongo.dsl.multiContextSuite +import kotlin.time.Instant + +val DateTimeValueOperatorsTest by multiContextSuite { + + class Target( + val date: Instant, + val year: Int, + ) + + test($$"$year") { + TestPipeline() + .set { + Target::year set Target::date.year + } + .shouldBeBson($$""" + [ + { + "$set": { + "year": { + "$year": "$date" + } + } + } + ] + """.trimIndent()) + } + +} -- 2.51.2 From 7eee35cf326b9b563da2de337cb945607334cde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sat, 8 Aug 2026 12:24:07 +0200 Subject: [PATCH 02/14] feat(dsl): Add $week (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 103 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 407 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 531 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index c215bbb4..dfcfb22d 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -137,6 +137,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$week`][DateTimeValueOperators.week] * - [`$year`][DateTimeValueOperators.year] * * Trigonometric operators and angle management: diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 42d4cc2c..3fe7671d 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -129,6 +129,109 @@ interface DateTimeValueOperators : ValueOperators { final val Value.year: Value get() = UnaryOperator(context, "year", this) + // endregion + // region $week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + val Value.week: Value + get() = UnaryOperator(context, "week", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfObjectId") + final val Value.week: Value + get() = UnaryOperator(context, "week", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfTimestamp") + final val Value.week: Value + get() = UnaryOperator(context, "week", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index aae5ba45..3aa52b6e 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -140,6 +140,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$week`][DateTimeValueOperators.week] * - [`$year`][DateTimeValueOperators.year] * * Trigonometric operators and angle management: diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 8d426f48..16e662bf 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -409,6 +409,413 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.year: Value get() = of(this).year + // endregion + // region $week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + val Value.week: Value + get() = UnaryOperator(context, "week", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.week: Value + get() = of(this).week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.week: Value + get() = of(this).week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.week: Value + get() = of(this).week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfObjectId") + final val Value.week: Value + get() = UnaryOperator(context, "week", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.week: Value + get() = of(this).week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfObjectId") + final val kotlin.reflect.KProperty1.week: Value + get() = of(this).week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfObjectId") + final val ObjectId.week: Value + get() = of(this).week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfTimestamp") + final val Value.week: Value + get() = UnaryOperator(context, "week", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.week: Value + get() = of(this).week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfTimestamp") + final val kotlin.reflect.KProperty1.week: Value + get() = of(this).week + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweek set User::birthdate.week + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekOfTimestamp") + final val Timestamp.week: Value + get() = of(this).week + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index 2a94ffac..16eece53 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -26,6 +26,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { class Target( val date: Instant, val year: Int, + val week: Int, ) test($$"$year") { @@ -46,4 +47,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$week") { + TestPipeline() + .set { + Target::week set Target::date.week + } + .shouldBeBson($$""" + [ + { + "$set": { + "week": { + "$week": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 3919a29313e041a12591d320af29e433f81394eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sat, 8 Aug 2026 12:31:17 +0200 Subject: [PATCH 03/14] feat(dsl): Add $second (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 94 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 371 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 486 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index dfcfb22d..f7fe29a9 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -137,6 +137,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$second`][DateTimeValueOperators.second] * - [`$week`][DateTimeValueOperators.week] * - [`$year`][DateTimeValueOperators.year] * diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 3fe7671d..1be8ef80 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -232,6 +232,100 @@ interface DateTimeValueOperators : ValueOperators { final val Value.week: Value get() = UnaryOperator(context, "week", this) + // endregion + // region $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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + val Value.second: Value + get() = UnaryOperator(context, "second", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfObjectId") + final val Value.second: Value + get() = UnaryOperator(context, "second", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfTimestamp") + final val Value.second: Value + get() = UnaryOperator(context, "second", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 3aa52b6e..bd07e9fd 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -140,6 +140,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$second`][DateTimeValueOperators.second] * - [`$week`][DateTimeValueOperators.week] * - [`$year`][DateTimeValueOperators.year] * diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 16e662bf..817372e7 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -816,6 +816,377 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.week: Value get() = of(this).week + // endregion + // region $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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + val Value.second: Value + get() = UnaryOperator(context, "second", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.second: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.second: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.second: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfObjectId") + final val Value.second: Value + get() = UnaryOperator(context, "second", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.second: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfObjectId") + final val kotlin.reflect.KProperty1.second: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfObjectId") + final val ObjectId.second: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfTimestamp") + final val Value.second: Value + get() = UnaryOperator(context, "second", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.second: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfTimestamp") + final val kotlin.reflect.KProperty1.second: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthsecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthsecond set User::birthdate.second + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/second/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("secondOfTimestamp") + final val Timestamp.second: Value + get() = of(this).second + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index 16eece53..18024dba 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -27,6 +27,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val date: Instant, val year: Int, val week: Int, + val second: Int, ) test($$"$year") { @@ -65,4 +66,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$second") { + TestPipeline() + .set { + Target::second set Target::date.second + } + .shouldBeBson($$""" + [ + { + "$set": { + "second": { + "$second": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 12bc565b4efb3d2d78b4001befe0d09e9f5ea5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sat, 8 Aug 2026 12:33:09 +0200 Subject: [PATCH 04/14] feat(dsl): Add $month (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 94 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 371 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 486 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index f7fe29a9..6ad2fdbe 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -137,6 +137,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$month`][DateTimeValueOperators.month] * - [`$second`][DateTimeValueOperators.second] * - [`$week`][DateTimeValueOperators.week] * - [`$year`][DateTimeValueOperators.year] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 1be8ef80..e76fca84 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -326,6 +326,100 @@ interface DateTimeValueOperators : ValueOperators { final val Value.second: Value get() = UnaryOperator(context, "second", this) + // endregion + // region $month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + val Value.month: Value + get() = UnaryOperator(context, "month", this) + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfObjectId") + final val Value.month: Value + get() = UnaryOperator(context, "month", this) + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfTimestamp") + final val Value.month: Value + get() = UnaryOperator(context, "month", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index bd07e9fd..f1891ca0 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -140,6 +140,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$month`][DateTimeValueOperators.month] * - [`$second`][DateTimeValueOperators.second] * - [`$week`][DateTimeValueOperators.week] * - [`$year`][DateTimeValueOperators.year] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 817372e7..c9a07acb 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -1187,6 +1187,377 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.second: Value get() = of(this).second + // endregion + // region $month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + val Value.month: Value + get() = UnaryOperator(context, "month", this) + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.month: Value + get() = of(this).month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.month: Value + get() = of(this).month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.month: Value + get() = of(this).month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfObjectId") + final val Value.month: Value + get() = UnaryOperator(context, "month", this) + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.month: Value + get() = of(this).month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfObjectId") + final val kotlin.reflect.KProperty1.month: Value + get() = of(this).month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfObjectId") + final val ObjectId.month: Value + get() = of(this).month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfTimestamp") + final val Value.month: Value + get() = UnaryOperator(context, "month", this) + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.month: Value + get() = of(this).month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfTimestamp") + final val kotlin.reflect.KProperty1.month: Value + get() = of(this).month + + /** + * Returns the month of a date as a number between `1` and `12`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmonth set User::birthdate.month + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/month/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("monthOfTimestamp") + final val Timestamp.month: Value + get() = of(this).month + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index 18024dba..1f9d6467 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -28,6 +28,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val year: Int, val week: Int, val second: Int, + val month: Int, ) test($$"$year") { @@ -84,4 +85,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$month") { + TestPipeline() + .set { + Target::month set Target::date.month + } + .shouldBeBson($$""" + [ + { + "$set": { + "month": { + "$month": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From a8437a4db42a2d30b2baf8d8f891a3a1518276e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sat, 8 Aug 2026 13:10:18 +0200 Subject: [PATCH 05/14] feat(dsl): Add $minute (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 94 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 371 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 486 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 6ad2fdbe..a77bae82 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -137,6 +137,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] * - [`$second`][DateTimeValueOperators.second] * - [`$week`][DateTimeValueOperators.week] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index e76fca84..ee4a1acd 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -420,6 +420,100 @@ interface DateTimeValueOperators : ValueOperators { final val Value.month: Value get() = UnaryOperator(context, "month", this) + // endregion + // region $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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + val Value.minute: Value + get() = UnaryOperator(context, "minute", this) + + /** + * Returns the minute portion of a date as a number between `0` and `59`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfObjectId") + final val Value.minute: Value + get() = UnaryOperator(context, "minute", this) + + /** + * Returns the minute portion of a date as a number between `0` and `59`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfTimestamp") + final val Value.minute: Value + get() = UnaryOperator(context, "minute", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index f1891ca0..100350af 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -140,6 +140,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] * - [`$second`][DateTimeValueOperators.second] * - [`$week`][DateTimeValueOperators.week] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index c9a07acb..2260b0d6 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -1558,6 +1558,377 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.month: Value get() = of(this).month + // endregion + // region $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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + val Value.minute: Value + get() = UnaryOperator(context, "minute", this) + + /** + * Returns the minute portion of a date as a number between `0` and `59`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.minute: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.minute: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.minute: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfObjectId") + final val Value.minute: Value + get() = UnaryOperator(context, "minute", this) + + /** + * Returns the minute portion of a date as a number between `0` and `59`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.minute: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfObjectId") + final val kotlin.reflect.KProperty1.minute: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfObjectId") + final val ObjectId.minute: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfTimestamp") + final val Value.minute: Value + get() = UnaryOperator(context, "minute", this) + + /** + * Returns the minute portion of a date as a number between `0` and `59`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.minute: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfTimestamp") + final val kotlin.reflect.KProperty1.minute: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthminute: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthminute set User::birthdate.minute + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/minute/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("minuteOfTimestamp") + final val Timestamp.minute: Value + get() = of(this).minute + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index 1f9d6467..182fe416 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -29,6 +29,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val week: Int, val second: Int, val month: Int, + val minute: Int, ) test($$"$year") { @@ -103,4 +104,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$minute") { + TestPipeline() + .set { + Target::minute set Target::date.minute + } + .shouldBeBson($$""" + [ + { + "$set": { + "minute": { + "$minute": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 3d03ceced19c1a0472f4995e476b88c49841160d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sun, 9 Aug 2026 08:57:11 +0200 Subject: [PATCH 06/14] feat(dsl): Add $millisecond (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 94 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 371 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 486 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index a77bae82..58aa1c42 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -137,6 +137,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$millisecond`][DateTimeValueOperators.millisecond] * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] * - [`$second`][DateTimeValueOperators.second] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index ee4a1acd..6e27eab3 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -514,6 +514,100 @@ interface DateTimeValueOperators : ValueOperators { final val Value.minute: Value get() = UnaryOperator(context, "minute", this) + // endregion + // region $millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + val Value.millisecond: Value + get() = UnaryOperator(context, "millisecond", this) + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfObjectId") + final val Value.millisecond: Value + get() = UnaryOperator(context, "millisecond", this) + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfTimestamp") + final val Value.millisecond: Value + get() = UnaryOperator(context, "millisecond", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 100350af..26c71e7e 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -140,6 +140,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$millisecond`][DateTimeValueOperators.millisecond] * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] * - [`$second`][DateTimeValueOperators.second] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 2260b0d6..f7218305 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -1929,6 +1929,377 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.minute: Value get() = of(this).minute + // endregion + // region $millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + val Value.millisecond: Value + get() = UnaryOperator(context, "millisecond", this) + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.millisecond: Value + get() = of(this).millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.millisecond: Value + get() = of(this).millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.millisecond: Value + get() = of(this).millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfObjectId") + final val Value.millisecond: Value + get() = UnaryOperator(context, "millisecond", this) + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.millisecond: Value + get() = of(this).millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfObjectId") + final val kotlin.reflect.KProperty1.millisecond: Value + get() = of(this).millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfObjectId") + final val ObjectId.millisecond: Value + get() = of(this).millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfTimestamp") + final val Value.millisecond: Value + get() = UnaryOperator(context, "millisecond", this) + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.millisecond: Value + get() = of(this).millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfTimestamp") + final val kotlin.reflect.KProperty1.millisecond: Value + get() = of(this).millisecond + + /** + * Returns the millisecond portion of a date as a number between `0` and `999`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthmillisecond: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthmillisecond set User::birthdate.millisecond + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/millisecond/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("millisecondOfTimestamp") + final val Timestamp.millisecond: Value + get() = of(this).millisecond + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index 182fe416..eea65d8f 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -30,6 +30,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val second: Int, val month: Int, val minute: Int, + val millisecond: Int, ) test($$"$year") { @@ -122,4 +123,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$millisecond") { + TestPipeline() + .set { + Target::millisecond set Target::date.millisecond + } + .shouldBeBson($$""" + [ + { + "$set": { + "millisecond": { + "$millisecond": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 33c6744356236a58d381b65afc57f8bfd2ede10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sun, 9 Aug 2026 09:04:35 +0200 Subject: [PATCH 07/14] feat(dsl): Add $isoWeek (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 103 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 407 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 531 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 58aa1c42..02858a9c 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -137,6 +137,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$isoWeek`][DateTimeValueOperators.weekIso] * - [`$millisecond`][DateTimeValueOperators.millisecond] * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 6e27eab3..eee294ff 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -608,6 +608,109 @@ interface DateTimeValueOperators : ValueOperators { final val Value.millisecond: Value get() = UnaryOperator(context, "millisecond", this) + // endregion + // region $isoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + val Value.weekIso: Value + get() = UnaryOperator(context, "isoWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfObjectId") + final val Value.weekIso: Value + get() = UnaryOperator(context, "isoWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfTimestamp") + final val Value.weekIso: Value + get() = UnaryOperator(context, "isoWeek", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 26c71e7e..643eda46 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -140,6 +140,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$isoWeek`][DateTimeValueOperators.weekIso] * - [`$millisecond`][DateTimeValueOperators.millisecond] * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index f7218305..d20c4216 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -2300,6 +2300,413 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.millisecond: Value get() = of(this).millisecond + // endregion + // region $isoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + val Value.weekIso: Value + get() = UnaryOperator(context, "isoWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.weekIso: Value + get() = of(this).weekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.weekIso: Value + get() = of(this).weekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.weekIso: Value + get() = of(this).weekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfObjectId") + final val Value.weekIso: Value + get() = UnaryOperator(context, "isoWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.weekIso: Value + get() = of(this).weekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfObjectId") + final val kotlin.reflect.KProperty1.weekIso: Value + get() = of(this).weekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfObjectId") + final val ObjectId.weekIso: Value + get() = of(this).weekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfTimestamp") + final val Value.weekIso: Value + get() = UnaryOperator(context, "isoWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.weekIso: Value + get() = of(this).weekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfTimestamp") + final val kotlin.reflect.KProperty1.weekIso: Value + get() = of(this).weekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthweekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthweekIso set User::birthdate.weekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("weekIsoOfTimestamp") + final val Timestamp.weekIso: Value + get() = of(this).weekIso + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index eea65d8f..aeb800ca 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -31,6 +31,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val month: Int, val minute: Int, val millisecond: Int, + val weekIso: Int, ) test($$"$year") { @@ -141,4 +142,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$isoWeek") { + TestPipeline() + .set { + Target::weekIso set Target::date.weekIso + } + .shouldBeBson($$""" + [ + { + "$set": { + "weekIso": { + "$isoWeek": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 0dbc460fcbd2e76975430acb7b1e1e7be824126a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sun, 9 Aug 2026 09:18:10 +0200 Subject: [PATCH 08/14] feat(dsl): Add $isoWeekYear (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 109 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 431 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 561 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 02858a9c..6ce9e36e 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -138,6 +138,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * * Date and time operators: * - [`$isoWeek`][DateTimeValueOperators.weekIso] + * - [`$isoWeekYear`][DateTimeValueOperators.yearOfIsoWeek] * - [`$millisecond`][DateTimeValueOperators.millisecond] * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index eee294ff..82377f26 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -711,6 +711,115 @@ interface DateTimeValueOperators : ValueOperators { final val Value.weekIso: Value get() = UnaryOperator(context, "isoWeek", this) + // endregion + // region $isoWeekYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + val Value.yearOfIsoWeek: Value + get() = UnaryOperator(context, "isoWeekYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfObjectId") + final val Value.yearOfIsoWeek: Value + get() = UnaryOperator(context, "isoWeekYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfTimestamp") + final val Value.yearOfIsoWeek: Value + get() = UnaryOperator(context, "isoWeekYear", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 643eda46..4084b512 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -141,6 +141,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * * Date and time operators: * - [`$isoWeek`][DateTimeValueOperators.weekIso] + * - [`$isoWeekYear`][DateTimeValueOperators.yearOfIsoWeek] * - [`$millisecond`][DateTimeValueOperators.millisecond] * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index d20c4216..e92a44f4 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -2707,6 +2707,437 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.weekIso: Value get() = of(this).weekIso + // endregion + // region $isoWeekYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + val Value.yearOfIsoWeek: Value + get() = UnaryOperator(context, "isoWeekYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.yearOfIsoWeek: Value + get() = of(this).yearOfIsoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.yearOfIsoWeek: Value + get() = of(this).yearOfIsoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.yearOfIsoWeek: Value + get() = of(this).yearOfIsoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfObjectId") + final val Value.yearOfIsoWeek: Value + get() = UnaryOperator(context, "isoWeekYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.yearOfIsoWeek: Value + get() = of(this).yearOfIsoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfObjectId") + final val kotlin.reflect.KProperty1.yearOfIsoWeek: Value + get() = of(this).yearOfIsoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfObjectId") + final val ObjectId.yearOfIsoWeek: Value + get() = of(this).yearOfIsoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfTimestamp") + final val Value.yearOfIsoWeek: Value + get() = UnaryOperator(context, "isoWeekYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.yearOfIsoWeek: Value + get() = of(this).yearOfIsoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfTimestamp") + final val kotlin.reflect.KProperty1.yearOfIsoWeek: Value + get() = of(this).yearOfIsoWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthyearOfIsoWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("yearOfIsoWeekOfTimestamp") + final val Timestamp.yearOfIsoWeek: Value + get() = of(this).yearOfIsoWeek + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index aeb800ca..bcc33358 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -32,6 +32,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val minute: Int, val millisecond: Int, val weekIso: Int, + val yearOfIsoWeek: Int, ) test($$"$year") { @@ -160,4 +161,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$isoWeekYear") { + TestPipeline() + .set { + Target::yearOfIsoWeek set Target::date.yearOfIsoWeek + } + .shouldBeBson($$""" + [ + { + "$set": { + "yearOfIsoWeek": { + "$isoWeekYear": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 3effce929ae47d055f0878a010d8d01a3de5bffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sun, 9 Aug 2026 09:30:14 +0200 Subject: [PATCH 09/14] feat(dsl): Add $isoDayOfWeek (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 100 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 395 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 516 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 6ce9e36e..87356b86 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -137,6 +137,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] * - [`$isoWeekYear`][DateTimeValueOperators.yearOfIsoWeek] * - [`$millisecond`][DateTimeValueOperators.millisecond] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 82377f26..5a7e8702 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -820,6 +820,106 @@ interface DateTimeValueOperators : ValueOperators { final val Value.yearOfIsoWeek: Value get() = UnaryOperator(context, "isoWeekYear", this) + // endregion + // region $isoDayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + val Value.dayOfWeekIso: Value + get() = UnaryOperator(context, "isoDayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfObjectId") + final val Value.dayOfWeekIso: Value + get() = UnaryOperator(context, "isoDayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfTimestamp") + final val Value.dayOfWeekIso: Value + get() = UnaryOperator(context, "isoDayOfWeek", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 4084b512..b35759c2 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -140,6 +140,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] * - [`$isoWeekYear`][DateTimeValueOperators.yearOfIsoWeek] * - [`$millisecond`][DateTimeValueOperators.millisecond] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index e92a44f4..9f5255cd 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -3138,6 +3138,401 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.yearOfIsoWeek: Value get() = of(this).yearOfIsoWeek + // endregion + // region $isoDayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + val Value.dayOfWeekIso: Value + get() = UnaryOperator(context, "isoDayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.dayOfWeekIso: Value + get() = of(this).dayOfWeekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.dayOfWeekIso: Value + get() = of(this).dayOfWeekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.dayOfWeekIso: Value + get() = of(this).dayOfWeekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfObjectId") + final val Value.dayOfWeekIso: Value + get() = UnaryOperator(context, "isoDayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.dayOfWeekIso: Value + get() = of(this).dayOfWeekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfObjectId") + final val kotlin.reflect.KProperty1.dayOfWeekIso: Value + get() = of(this).dayOfWeekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfObjectId") + final val ObjectId.dayOfWeekIso: Value + get() = of(this).dayOfWeekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfTimestamp") + final val Value.dayOfWeekIso: Value + get() = UnaryOperator(context, "isoDayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.dayOfWeekIso: Value + get() = of(this).dayOfWeekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfTimestamp") + final val kotlin.reflect.KProperty1.dayOfWeekIso: Value + get() = of(this).dayOfWeekIso + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeekIso: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekIsoOfTimestamp") + final val Timestamp.dayOfWeekIso: Value + get() = of(this).dayOfWeekIso + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index bcc33358..5926caa1 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -33,6 +33,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val millisecond: Int, val weekIso: Int, val yearOfIsoWeek: Int, + val dayOfWeekIso: Int, ) test($$"$year") { @@ -179,4 +180,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$isoDayOfWeek") { + TestPipeline() + .set { + Target::dayOfWeekIso set Target::date.dayOfWeekIso + } + .shouldBeBson($$""" + [ + { + "$set": { + "dayOfWeekIso": { + "$isoDayOfWeek": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 9afc40581ebce791bf0e1eaab626fda57aaa456d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sun, 9 Aug 2026 09:34:44 +0200 Subject: [PATCH 10/14] feat(dsl): Add $hour (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 94 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 371 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 486 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 87356b86..942eef65 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -137,6 +137,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$hour`][DateTimeValueOperators.hour] * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] * - [`$isoWeekYear`][DateTimeValueOperators.yearOfIsoWeek] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 5a7e8702..b0bcd11c 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -920,6 +920,100 @@ interface DateTimeValueOperators : ValueOperators { final val Value.dayOfWeekIso: Value get() = UnaryOperator(context, "isoDayOfWeek", this) + // endregion + // region $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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + val Value.hour: Value + get() = UnaryOperator(context, "hour", this) + + /** + * Returns the hour portion of a date as a number between `0` and `23`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfObjectId") + final val Value.hour: Value + get() = UnaryOperator(context, "hour", this) + + /** + * Returns the hour portion of a date as a number between `0` and `23`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfTimestamp") + final val Value.hour: Value + get() = UnaryOperator(context, "hour", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index b35759c2..534d9dd5 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -140,6 +140,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$hour`][DateTimeValueOperators.hour] * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] * - [`$isoWeekYear`][DateTimeValueOperators.yearOfIsoWeek] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 9f5255cd..44dad631 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -3533,6 +3533,377 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.dayOfWeekIso: Value get() = of(this).dayOfWeekIso + // endregion + // region $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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + val Value.hour: Value + get() = UnaryOperator(context, "hour", this) + + /** + * Returns the hour portion of a date as a number between `0` and `23`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.hour: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.hour: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.hour: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfObjectId") + final val Value.hour: Value + get() = UnaryOperator(context, "hour", this) + + /** + * Returns the hour portion of a date as a number between `0` and `23`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.hour: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfObjectId") + final val kotlin.reflect.KProperty1.hour: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfObjectId") + final val ObjectId.hour: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfTimestamp") + final val Value.hour: Value + get() = UnaryOperator(context, "hour", this) + + /** + * Returns the hour portion of a date as a number between `0` and `23`. + * + * The accepted date types are [Instant], [ObjectId] and [Timestamp]. + * + * ### Example + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.hour: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfTimestamp") + final val kotlin.reflect.KProperty1.hour: Value + get() = of(this).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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthhour: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthhour set User::birthdate.hour + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/hour/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("hourOfTimestamp") + final val Timestamp.hour: Value + get() = of(this).hour + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index 5926caa1..5c6d49b6 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -34,6 +34,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val weekIso: Int, val yearOfIsoWeek: Int, val dayOfWeekIso: Int, + val hour: Int, ) test($$"$year") { @@ -198,4 +199,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$hour") { + TestPipeline() + .set { + Target::hour set Target::date.hour + } + .shouldBeBson($$""" + [ + { + "$set": { + "hour": { + "$hour": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 0b16dcf3d2fffad9611ef3ded03edd4402b52895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sun, 9 Aug 2026 09:39:40 +0200 Subject: [PATCH 11/14] feat(dsl): Add $dayOfMonth (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 94 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 371 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 486 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 942eef65..56f1fee3 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -137,6 +137,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$dayOfMonth`][DateTimeValueOperators.dayOfMonth] * - [`$hour`][DateTimeValueOperators.hour] * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index b0bcd11c..ef284410 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -1014,6 +1014,100 @@ interface DateTimeValueOperators : ValueOperators { final val Value.hour: Value get() = UnaryOperator(context, "hour", this) + // endregion + // region $dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + val Value.dayOfMonth: Value + get() = UnaryOperator(context, "dayOfMonth", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfObjectId") + final val Value.dayOfMonth: Value + get() = UnaryOperator(context, "dayOfMonth", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfTimestamp") + final val Value.dayOfMonth: Value + get() = UnaryOperator(context, "dayOfMonth", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 534d9dd5..d9d337f7 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -140,6 +140,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * - [`$toUUID`][TypeValueOperators.toUuid] * * Date and time operators: + * - [`$dayOfMonth`][DateTimeValueOperators.dayOfMonth] * - [`$hour`][DateTimeValueOperators.hour] * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 44dad631..97357b27 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -3904,6 +3904,377 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.hour: Value get() = of(this).hour + // endregion + // region $dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + val Value.dayOfMonth: Value + get() = UnaryOperator(context, "dayOfMonth", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.dayOfMonth: Value + get() = of(this).dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.dayOfMonth: Value + get() = of(this).dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.dayOfMonth: Value + get() = of(this).dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfObjectId") + final val Value.dayOfMonth: Value + get() = UnaryOperator(context, "dayOfMonth", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.dayOfMonth: Value + get() = of(this).dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfObjectId") + final val kotlin.reflect.KProperty1.dayOfMonth: Value + get() = of(this).dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfObjectId") + final val ObjectId.dayOfMonth: Value + get() = of(this).dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfTimestamp") + final val Value.dayOfMonth: Value + get() = UnaryOperator(context, "dayOfMonth", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.dayOfMonth: Value + get() = of(this).dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfTimestamp") + final val kotlin.reflect.KProperty1.dayOfMonth: Value + get() = of(this).dayOfMonth + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfMonth: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfMonth set User::birthdate.dayOfMonth + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfMonth/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfMonthOfTimestamp") + final val Timestamp.dayOfMonth: Value + get() = of(this).dayOfMonth + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index 5c6d49b6..a0dfd34c 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -35,6 +35,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val yearOfIsoWeek: Int, val dayOfWeekIso: Int, val hour: Int, + val dayOfMonth: Int, ) test($$"$year") { @@ -217,4 +218,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$dayOfMonth") { + TestPipeline() + .set { + Target::dayOfMonth set Target::date.dayOfMonth + } + .shouldBeBson($$""" + [ + { + "$set": { + "dayOfMonth": { + "$dayOfMonth": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 0f026dfb3da0bf90f20e509d0d3c669838883561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sun, 9 Aug 2026 09:46:30 +0200 Subject: [PATCH 12/14] feat(dsl): Add $dayOfWeek (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 100 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 395 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 516 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 56f1fee3..27072c03 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -138,6 +138,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * * Date and time operators: * - [`$dayOfMonth`][DateTimeValueOperators.dayOfMonth] + * - [`$dayOfWeek`][DateTimeValueOperators.dayOfWeek] * - [`$hour`][DateTimeValueOperators.hour] * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index ef284410..30bba561 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -1108,6 +1108,106 @@ interface DateTimeValueOperators : ValueOperators { final val Value.dayOfMonth: Value get() = UnaryOperator(context, "dayOfMonth", this) + // endregion + // region $dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + val Value.dayOfWeek: Value + get() = UnaryOperator(context, "dayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfObjectId") + final val Value.dayOfWeek: Value + get() = UnaryOperator(context, "dayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfTimestamp") + final val Value.dayOfWeek: Value + get() = UnaryOperator(context, "dayOfWeek", this) + // endregion @LowLevelApi diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index d9d337f7..bace745f 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -141,6 +141,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * * Date and time operators: * - [`$dayOfMonth`][DateTimeValueOperators.dayOfMonth] + * - [`$dayOfWeek`][DateTimeValueOperators.dayOfWeek] * - [`$hour`][DateTimeValueOperators.hour] * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 97357b27..4a0986a1 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -4275,6 +4275,401 @@ interface DateTimeValueOperators : ValueOperators { final val Timestamp.dayOfMonth: Value get() = of(this).dayOfMonth + // endregion + // region $dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + val Value.dayOfWeek: Value + get() = UnaryOperator(context, "dayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.dayOfWeek: Value + get() = of(this).dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.dayOfWeek: Value + get() = of(this).dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.dayOfWeek: Value + get() = of(this).dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfObjectId") + final val Value.dayOfWeek: Value + get() = UnaryOperator(context, "dayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.dayOfWeek: Value + get() = of(this).dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfObjectId") + final val kotlin.reflect.KProperty1.dayOfWeek: Value + get() = of(this).dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfObjectId") + final val ObjectId.dayOfWeek: Value + get() = of(this).dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfTimestamp") + final val Value.dayOfWeek: Value + get() = UnaryOperator(context, "dayOfWeek", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.dayOfWeek: Value + get() = of(this).dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfTimestamp") + final val kotlin.reflect.KProperty1.dayOfWeek: Value + get() = of(this).dayOfWeek + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfWeek: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfWeek set User::birthdate.dayOfWeek + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfWeekOfTimestamp") + final val Timestamp.dayOfWeek: Value + get() = of(this).dayOfWeek + // endregion @LowLevelApi diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index a0dfd34c..291fcf30 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -36,6 +36,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val dayOfWeekIso: Int, val hour: Int, val dayOfMonth: Int, + val dayOfWeek: Int, ) test($$"$year") { @@ -236,4 +237,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$dayOfWeek") { + TestPipeline() + .set { + Target::dayOfWeek set Target::date.dayOfWeek + } + .shouldBeBson($$""" + [ + { + "$set": { + "dayOfWeek": { + "$dayOfWeek": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From 11d8146b100fa415b1544d1642bb1f580ec6f485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sun, 9 Aug 2026 09:59:46 +0200 Subject: [PATCH 13/14] feat(dsl): Add $dayOfYear (aggregation) --- .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 101 +++++ .../aggregation/AggregationOperators.kt | 1 + .../operators/DateTimeValueOperators.kt | 396 ++++++++++++++++++ .../operators/DateTimeValueOperatorsTest.kt | 19 + 5 files changed, 518 insertions(+) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 27072c03..f7f9cf9a 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -139,6 +139,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * Date and time operators: * - [`$dayOfMonth`][DateTimeValueOperators.dayOfMonth] * - [`$dayOfWeek`][DateTimeValueOperators.dayOfWeek] + * - [`$dayOfYear`][DateTimeValueOperators.dayOfYear] * - [`$hour`][DateTimeValueOperators.hour] * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 30bba561..f756f2c6 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -1210,6 +1210,107 @@ interface DateTimeValueOperators : ValueOperators { // endregion + // region $dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + val Value.dayOfYear: Value + get() = UnaryOperator(context, "dayOfYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfObjectId") + final val Value.dayOfYear: Value + get() = UnaryOperator(context, "dayOfYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfTimestamp") + final val Value.dayOfYear: Value + get() = UnaryOperator(context, "dayOfYear", this) + + // endregion + @LowLevelApi private class UnaryOperator( context: BsonContext, diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index bace745f..68b20f2d 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -142,6 +142,7 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * Date and time operators: * - [`$dayOfMonth`][DateTimeValueOperators.dayOfMonth] * - [`$dayOfWeek`][DateTimeValueOperators.dayOfWeek] + * - [`$dayOfYear`][DateTimeValueOperators.dayOfYear] * - [`$hour`][DateTimeValueOperators.hour] * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] * - [`$isoWeek`][DateTimeValueOperators.weekIso] diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index 4a0986a1..c714213a 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -4672,6 +4672,402 @@ interface DateTimeValueOperators : ValueOperators { // endregion + // region $dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + val Value.dayOfYear: Value + get() = UnaryOperator(context, "dayOfYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + val opensavvy.ktmongo.dsl.path.Field.dayOfYear: Value + get() = of(this).dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + val kotlin.reflect.KProperty1.dayOfYear: Value + get() = of(this).dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @Suppress("INVISIBLE_REFERENCE") + @OptIn(LowLevelApi::class) + val Instant.dayOfYear: Value + get() = of(this).dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfObjectId") + final val Value.dayOfYear: Value + get() = UnaryOperator(context, "dayOfYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.dayOfYear: Value + get() = of(this).dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfObjectId") + final val kotlin.reflect.KProperty1.dayOfYear: Value + get() = of(this).dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfObjectId") + final val ObjectId.dayOfYear: Value + get() = of(this).dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfTimestamp") + final val Value.dayOfYear: Value + get() = UnaryOperator(context, "dayOfYear", this) + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.dayOfYear: Value + get() = of(this).dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @OptIn(LowLevelApi::class) + @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfTimestamp") + final val kotlin.reflect.KProperty1.dayOfYear: Value + get() = of(this).dayOfYear + + /** + * 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 + * + * ```kotlin + * class User( + * val name: String, + * val birthdate: Instant, + * val birthdayOfYear: Int? = null, + * ) + * + * users.updateManyWithPipeline { + * set { + * User::birthdayOfYear set User::birthdate.dayOfYear + * } + * } + * ``` + * + * ### External resources + * + * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfYear/) + */ + @kotlin.internal.LowPriorityInOverloadResolution + @OptIn(LowLevelApi::class) + @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") + @get:JvmName("dayOfYearOfTimestamp") + final val Timestamp.dayOfYear: Value + get() = of(this).dayOfYear + + // endregion + @LowLevelApi private class UnaryOperator( context: BsonContext, diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index 291fcf30..6eafc4c2 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -37,6 +37,7 @@ val DateTimeValueOperatorsTest by multiContextSuite { val hour: Int, val dayOfMonth: Int, val dayOfWeek: Int, + val dayOfYear: Int, ) test($$"$year") { @@ -255,4 +256,22 @@ val DateTimeValueOperatorsTest by multiContextSuite { """.trimIndent()) } + test($$"$dayOfYear") { + TestPipeline() + .set { + Target::dayOfYear set Target::date.dayOfYear + } + .shouldBeBson($$""" + [ + { + "$set": { + "dayOfYear": { + "$dayOfYear": "$date" + } + } + } + ] + """.trimIndent()) + } + } -- 2.51.2 From a862d85a356356f23b9187c3471982fd8737f61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sun, 9 Aug 2026 10:20:16 +0200 Subject: [PATCH 14/14] feat(dsl): Clarify between the US and ISO week numbering systems --- .../aggregation/AggregationOperators.kt | 10 +- .../operators/DateTimeValueOperators.kt | 134 ++-- .../aggregation/AggregationOperators.kt | 10 +- .../operators/DateTimeValueOperators.kt | 626 +++++++++--------- .../operators/DateTimeValueOperatorsTest.kt | 30 +- 5 files changed, 405 insertions(+), 405 deletions(-) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt index f7f9cf9a..6858469d 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -138,17 +138,17 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * * Date and time operators: * - [`$dayOfMonth`][DateTimeValueOperators.dayOfMonth] - * - [`$dayOfWeek`][DateTimeValueOperators.dayOfWeek] + * - [`$dayOfWeek`][DateTimeValueOperators.dayOfWeekUS] * - [`$dayOfYear`][DateTimeValueOperators.dayOfYear] * - [`$hour`][DateTimeValueOperators.hour] - * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] - * - [`$isoWeek`][DateTimeValueOperators.weekIso] - * - [`$isoWeekYear`][DateTimeValueOperators.yearOfIsoWeek] + * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekISO] + * - [`$isoWeek`][DateTimeValueOperators.weekISO] + * - [`$isoWeekYear`][DateTimeValueOperators.yearOfISOWeek] * - [`$millisecond`][DateTimeValueOperators.millisecond] * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] * - [`$second`][DateTimeValueOperators.second] - * - [`$week`][DateTimeValueOperators.week] + * - [`$week`][DateTimeValueOperators.weekUS] * - [`$year`][DateTimeValueOperators.year] * * Trigonometric operators and angle management: diff --git a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index f756f2c6..29daa3c3 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -146,12 +146,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -161,7 +161,7 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) */ @OptIn(LowLevelApi::class) - val Value.week: Value + val Value.weekUS: Value get() = UnaryOperator(context, "week", this) /** @@ -178,12 +178,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -194,8 +194,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfObjectId") - final val Value.week: Value + @get:JvmName("weekUSOfObjectId") + final val Value.weekUS: Value get() = UnaryOperator(context, "week", this) /** @@ -212,12 +212,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -228,8 +228,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfTimestamp") - final val Value.week: Value + @get:JvmName("weekUSOfTimestamp") + final val Value.weekUS: Value get() = UnaryOperator(context, "week", this) // endregion @@ -625,12 +625,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -640,7 +640,7 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) */ @OptIn(LowLevelApi::class) - val Value.weekIso: Value + val Value.weekISO: Value get() = UnaryOperator(context, "isoWeek", this) /** @@ -657,12 +657,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -673,8 +673,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfObjectId") - final val Value.weekIso: Value + @get:JvmName("weekISOOfObjectId") + final val Value.weekISO: Value get() = UnaryOperator(context, "isoWeek", this) /** @@ -691,12 +691,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -707,8 +707,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfTimestamp") - final val Value.weekIso: Value + @get:JvmName("weekISOOfTimestamp") + final val Value.weekISO: Value get() = UnaryOperator(context, "isoWeek", this) // endregion @@ -716,9 +716,9 @@ interface DateTimeValueOperators : ValueOperators { /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -730,12 +730,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -745,14 +745,14 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) */ @OptIn(LowLevelApi::class) - val Value.yearOfIsoWeek: Value + val Value.yearOfISOWeek: Value get() = UnaryOperator(context, "isoWeekYear", this) /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -764,12 +764,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -780,15 +780,15 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfObjectId") - final val Value.yearOfIsoWeek: Value + @get:JvmName("yearOfISOWeekOfObjectId") + final val Value.yearOfISOWeek: Value get() = UnaryOperator(context, "isoWeekYear", this) /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -800,12 +800,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -816,8 +816,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfTimestamp") - final val Value.yearOfIsoWeek: Value + @get:JvmName("yearOfISOWeekOfTimestamp") + final val Value.yearOfISOWeek: Value get() = UnaryOperator(context, "isoWeekYear", this) // endregion @@ -826,7 +826,7 @@ interface DateTimeValueOperators : ValueOperators { /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -836,12 +836,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -851,13 +851,13 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) */ @OptIn(LowLevelApi::class) - val Value.dayOfWeekIso: Value + val Value.dayOfWeekISO: Value get() = UnaryOperator(context, "isoDayOfWeek", this) /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -867,12 +867,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -883,14 +883,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfObjectId") - final val Value.dayOfWeekIso: Value + @get:JvmName("dayOfWeekISOOfObjectId") + final val Value.dayOfWeekISO: Value get() = UnaryOperator(context, "isoDayOfWeek", this) /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -900,12 +900,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -916,8 +916,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfTimestamp") - final val Value.dayOfWeekIso: Value + @get:JvmName("dayOfWeekISOOfTimestamp") + final val Value.dayOfWeekISO: Value get() = UnaryOperator(context, "isoDayOfWeek", this) // endregion @@ -1114,7 +1114,7 @@ interface DateTimeValueOperators : ValueOperators { /** * 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]. + * 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]. * @@ -1124,12 +1124,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -1139,13 +1139,13 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) */ @OptIn(LowLevelApi::class) - val Value.dayOfWeek: Value + val Value.dayOfWeekUS: Value get() = UnaryOperator(context, "dayOfWeek", this) /** * 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]. + * 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]. * @@ -1155,12 +1155,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -1171,14 +1171,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfObjectId") - final val Value.dayOfWeek: Value + @get:JvmName("dayOfWeekUSOfObjectId") + final val Value.dayOfWeekUS: Value get() = UnaryOperator(context, "dayOfWeek", this) /** * 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]. + * 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]. * @@ -1188,12 +1188,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -1204,8 +1204,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfTimestamp") - final val Value.dayOfWeek: Value + @get:JvmName("dayOfWeekUSOfTimestamp") + final val Value.dayOfWeekUS: Value get() = UnaryOperator(context, "dayOfWeek", this) // endregion diff --git a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt index 68b20f2d..786436cb 100644 --- a/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/AggregationOperators.kt @@ -141,17 +141,17 @@ import opensavvy.ktmongo.dsl.query.FilterQuery * * Date and time operators: * - [`$dayOfMonth`][DateTimeValueOperators.dayOfMonth] - * - [`$dayOfWeek`][DateTimeValueOperators.dayOfWeek] + * - [`$dayOfWeek`][DateTimeValueOperators.dayOfWeekUS] * - [`$dayOfYear`][DateTimeValueOperators.dayOfYear] * - [`$hour`][DateTimeValueOperators.hour] - * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekIso] - * - [`$isoWeek`][DateTimeValueOperators.weekIso] - * - [`$isoWeekYear`][DateTimeValueOperators.yearOfIsoWeek] + * - [`$isoDayOfWeek`][DateTimeValueOperators.dayOfWeekISO] + * - [`$isoWeek`][DateTimeValueOperators.weekISO] + * - [`$isoWeekYear`][DateTimeValueOperators.yearOfISOWeek] * - [`$millisecond`][DateTimeValueOperators.millisecond] * - [`$minute`][DateTimeValueOperators.minute] * - [`$month`][DateTimeValueOperators.month] * - [`$second`][DateTimeValueOperators.second] - * - [`$week`][DateTimeValueOperators.week] + * - [`$week`][DateTimeValueOperators.weekUS] * - [`$year`][DateTimeValueOperators.year] * * Trigonometric operators and angle management: diff --git a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt index c714213a..b555768a 100644 --- a/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt +++ b/dsl/src/commonMain/kotlin/aggregation/operators/DateTimeValueOperators.kt @@ -426,12 +426,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -441,7 +441,7 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) */ @OptIn(LowLevelApi::class) - val Value.week: Value + val Value.weekUS: Value get() = UnaryOperator(context, "week", this) /** @@ -458,12 +458,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -473,8 +473,8 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) */ @OptIn(LowLevelApi::class) - val opensavvy.ktmongo.dsl.path.Field.week: Value - get() = of(this).week + val opensavvy.ktmongo.dsl.path.Field.weekUS: Value + get() = of(this).weekUS /** * Returns the week of the year for a date, ranging from `0` to `53`. @@ -490,12 +490,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -505,8 +505,8 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/week/) */ @OptIn(LowLevelApi::class) - val kotlin.reflect.KProperty1.week: Value - get() = of(this).week + val kotlin.reflect.KProperty1.weekUS: Value + get() = of(this).weekUS /** * Returns the week of the year for a date, ranging from `0` to `53`. @@ -522,12 +522,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -539,8 +539,8 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @Suppress("INVISIBLE_REFERENCE") @OptIn(LowLevelApi::class) - val Instant.week: Value - get() = of(this).week + val Instant.weekUS: Value + get() = of(this).weekUS /** * Returns the week of the year for a date, ranging from `0` to `53`. @@ -556,12 +556,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -572,8 +572,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfObjectId") - final val Value.week: Value + @get:JvmName("weekUSOfObjectId") + final val Value.weekUS: Value get() = UnaryOperator(context, "week", this) /** @@ -590,12 +590,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -606,9 +606,9 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfObjectId") - final val opensavvy.ktmongo.dsl.path.Field.week: Value - get() = of(this).week + @get:JvmName("weekUSOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.weekUS: Value + get() = of(this).weekUS /** * Returns the week of the year for a date, ranging from `0` to `53`. @@ -624,12 +624,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -640,9 +640,9 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfObjectId") - final val kotlin.reflect.KProperty1.week: Value - get() = of(this).week + @get:JvmName("weekUSOfObjectId") + final val kotlin.reflect.KProperty1.weekUS: Value + get() = of(this).weekUS /** * Returns the week of the year for a date, ranging from `0` to `53`. @@ -658,12 +658,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -675,9 +675,9 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfObjectId") - final val ObjectId.week: Value - get() = of(this).week + @get:JvmName("weekUSOfObjectId") + final val ObjectId.weekUS: Value + get() = of(this).weekUS /** * Returns the week of the year for a date, ranging from `0` to `53`. @@ -693,12 +693,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -709,8 +709,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfTimestamp") - final val Value.week: Value + @get:JvmName("weekUSOfTimestamp") + final val Value.weekUS: Value get() = UnaryOperator(context, "week", this) /** @@ -727,12 +727,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -743,9 +743,9 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfTimestamp") - final val opensavvy.ktmongo.dsl.path.Field.week: Value - get() = of(this).week + @get:JvmName("weekUSOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.weekUS: Value + get() = of(this).weekUS /** * Returns the week of the year for a date, ranging from `0` to `53`. @@ -761,12 +761,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -777,9 +777,9 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfTimestamp") - final val kotlin.reflect.KProperty1.week: Value - get() = of(this).week + @get:JvmName("weekUSOfTimestamp") + final val kotlin.reflect.KProperty1.weekUS: Value + get() = of(this).weekUS /** * Returns the week of the year for a date, ranging from `0` to `53`. @@ -795,12 +795,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweek: Int? = null, + * val birthweekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweek set User::birthdate.week + * User::birthweekUS set User::birthdate.weekUS * } * } * ``` @@ -812,9 +812,9 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekOfTimestamp") - final val Timestamp.week: Value - get() = of(this).week + @get:JvmName("weekUSOfTimestamp") + final val Timestamp.weekUS: Value + get() = of(this).weekUS // endregion // region $second @@ -2317,12 +2317,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2332,7 +2332,7 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) */ @OptIn(LowLevelApi::class) - val Value.weekIso: Value + val Value.weekISO: Value get() = UnaryOperator(context, "isoWeek", this) /** @@ -2349,12 +2349,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2364,8 +2364,8 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) */ @OptIn(LowLevelApi::class) - val opensavvy.ktmongo.dsl.path.Field.weekIso: Value - get() = of(this).weekIso + val opensavvy.ktmongo.dsl.path.Field.weekISO: Value + get() = of(this).weekISO /** * Returns the week number in ISO 8601 format, ranging from `1` to `53`. @@ -2381,12 +2381,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2396,8 +2396,8 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeek/) */ @OptIn(LowLevelApi::class) - val kotlin.reflect.KProperty1.weekIso: Value - get() = of(this).weekIso + val kotlin.reflect.KProperty1.weekISO: Value + get() = of(this).weekISO /** * Returns the week number in ISO 8601 format, ranging from `1` to `53`. @@ -2413,12 +2413,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2430,8 +2430,8 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @Suppress("INVISIBLE_REFERENCE") @OptIn(LowLevelApi::class) - val Instant.weekIso: Value - get() = of(this).weekIso + val Instant.weekISO: Value + get() = of(this).weekISO /** * Returns the week number in ISO 8601 format, ranging from `1` to `53`. @@ -2447,12 +2447,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2463,8 +2463,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfObjectId") - final val Value.weekIso: Value + @get:JvmName("weekISOOfObjectId") + final val Value.weekISO: Value get() = UnaryOperator(context, "isoWeek", this) /** @@ -2481,12 +2481,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2497,9 +2497,9 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfObjectId") - final val opensavvy.ktmongo.dsl.path.Field.weekIso: Value - get() = of(this).weekIso + @get:JvmName("weekISOOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.weekISO: Value + get() = of(this).weekISO /** * Returns the week number in ISO 8601 format, ranging from `1` to `53`. @@ -2515,12 +2515,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2531,9 +2531,9 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfObjectId") - final val kotlin.reflect.KProperty1.weekIso: Value - get() = of(this).weekIso + @get:JvmName("weekISOOfObjectId") + final val kotlin.reflect.KProperty1.weekISO: Value + get() = of(this).weekISO /** * Returns the week number in ISO 8601 format, ranging from `1` to `53`. @@ -2549,12 +2549,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2566,9 +2566,9 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfObjectId") - final val ObjectId.weekIso: Value - get() = of(this).weekIso + @get:JvmName("weekISOOfObjectId") + final val ObjectId.weekISO: Value + get() = of(this).weekISO /** * Returns the week number in ISO 8601 format, ranging from `1` to `53`. @@ -2584,12 +2584,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2600,8 +2600,8 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfTimestamp") - final val Value.weekIso: Value + @get:JvmName("weekISOOfTimestamp") + final val Value.weekISO: Value get() = UnaryOperator(context, "isoWeek", this) /** @@ -2618,12 +2618,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2634,9 +2634,9 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfTimestamp") - final val opensavvy.ktmongo.dsl.path.Field.weekIso: Value - get() = of(this).weekIso + @get:JvmName("weekISOOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.weekISO: Value + get() = of(this).weekISO /** * Returns the week number in ISO 8601 format, ranging from `1` to `53`. @@ -2652,12 +2652,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2668,9 +2668,9 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfTimestamp") - final val kotlin.reflect.KProperty1.weekIso: Value - get() = of(this).weekIso + @get:JvmName("weekISOOfTimestamp") + final val kotlin.reflect.KProperty1.weekISO: Value + get() = of(this).weekISO /** * Returns the week number in ISO 8601 format, ranging from `1` to `53`. @@ -2686,12 +2686,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthweekIso: Int? = null, + * val birthweekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthweekIso set User::birthdate.weekIso + * User::birthweekISO set User::birthdate.weekISO * } * } * ``` @@ -2703,18 +2703,18 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("weekIsoOfTimestamp") - final val Timestamp.weekIso: Value - get() = of(this).weekIso + @get:JvmName("weekISOOfTimestamp") + final val Timestamp.weekISO: Value + get() = of(this).weekISO // endregion // region $isoWeekYear /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -2726,12 +2726,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -2741,14 +2741,14 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) */ @OptIn(LowLevelApi::class) - val Value.yearOfIsoWeek: Value + val Value.yearOfISOWeek: Value get() = UnaryOperator(context, "isoWeekYear", this) /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -2760,12 +2760,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -2775,14 +2775,14 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) */ @OptIn(LowLevelApi::class) - val opensavvy.ktmongo.dsl.path.Field.yearOfIsoWeek: Value - get() = of(this).yearOfIsoWeek + val opensavvy.ktmongo.dsl.path.Field.yearOfISOWeek: Value + get() = of(this).yearOfISOWeek /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -2794,12 +2794,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -2809,14 +2809,14 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoWeekYear/) */ @OptIn(LowLevelApi::class) - val kotlin.reflect.KProperty1.yearOfIsoWeek: Value - get() = of(this).yearOfIsoWeek + val kotlin.reflect.KProperty1.yearOfISOWeek: Value + get() = of(this).yearOfISOWeek /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -2828,12 +2828,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -2845,14 +2845,14 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @Suppress("INVISIBLE_REFERENCE") @OptIn(LowLevelApi::class) - val Instant.yearOfIsoWeek: Value - get() = of(this).yearOfIsoWeek + val Instant.yearOfISOWeek: Value + get() = of(this).yearOfISOWeek /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -2864,12 +2864,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -2880,15 +2880,15 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfObjectId") - final val Value.yearOfIsoWeek: Value + @get:JvmName("yearOfISOWeekOfObjectId") + final val Value.yearOfISOWeek: Value get() = UnaryOperator(context, "isoWeekYear", this) /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -2900,12 +2900,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -2916,15 +2916,15 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfObjectId") - final val opensavvy.ktmongo.dsl.path.Field.yearOfIsoWeek: Value - get() = of(this).yearOfIsoWeek + @get:JvmName("yearOfISOWeekOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.yearOfISOWeek: Value + get() = of(this).yearOfISOWeek /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -2936,12 +2936,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -2952,15 +2952,15 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfObjectId") - final val kotlin.reflect.KProperty1.yearOfIsoWeek: Value - get() = of(this).yearOfIsoWeek + @get:JvmName("yearOfISOWeekOfObjectId") + final val kotlin.reflect.KProperty1.yearOfISOWeek: Value + get() = of(this).yearOfISOWeek /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -2972,12 +2972,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -2989,15 +2989,15 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfObjectId") - final val ObjectId.yearOfIsoWeek: Value - get() = of(this).yearOfIsoWeek + @get:JvmName("yearOfISOWeekOfObjectId") + final val ObjectId.yearOfISOWeek: Value + get() = of(this).yearOfISOWeek /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -3009,12 +3009,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -3025,15 +3025,15 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfTimestamp") - final val Value.yearOfIsoWeek: Value + @get:JvmName("yearOfISOWeekOfTimestamp") + final val Value.yearOfISOWeek: Value get() = UnaryOperator(context, "isoWeekYear", this) /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -3045,12 +3045,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -3061,15 +3061,15 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfTimestamp") - final val opensavvy.ktmongo.dsl.path.Field.yearOfIsoWeek: Value - get() = of(this).yearOfIsoWeek + @get:JvmName("yearOfISOWeekOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.yearOfISOWeek: Value + get() = of(this).yearOfISOWeek /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -3081,12 +3081,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -3097,15 +3097,15 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfTimestamp") - final val kotlin.reflect.KProperty1.yearOfIsoWeek: Value - get() = of(this).yearOfIsoWeek + @get:JvmName("yearOfISOWeekOfTimestamp") + final val kotlin.reflect.KProperty1.yearOfISOWeek: Value + get() = of(this).yearOfISOWeek /** * Returns the year in ISO 8601 format, corresponding to the ISO week number returned by - * [weekIso]. + * [weekISO]. * - * The year always starts on the first day of [weekIso] 1, which must be a Monday. + * 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. * @@ -3117,12 +3117,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthyearOfIsoWeek: Int? = null, + * val birthyearOfISOWeek: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthyearOfIsoWeek set User::birthdate.yearOfIsoWeek + * User::birthyearOfISOWeek set User::birthdate.yearOfISOWeek * } * } * ``` @@ -3134,9 +3134,9 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("yearOfIsoWeekOfTimestamp") - final val Timestamp.yearOfIsoWeek: Value - get() = of(this).yearOfIsoWeek + @get:JvmName("yearOfISOWeekOfTimestamp") + final val Timestamp.yearOfISOWeek: Value + get() = of(this).yearOfISOWeek // endregion // region $isoDayOfWeek @@ -3144,7 +3144,7 @@ interface DateTimeValueOperators : ValueOperators { /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3154,12 +3154,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3169,13 +3169,13 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) */ @OptIn(LowLevelApi::class) - val Value.dayOfWeekIso: Value + val Value.dayOfWeekISO: Value get() = UnaryOperator(context, "isoDayOfWeek", this) /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3185,12 +3185,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3200,13 +3200,13 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) */ @OptIn(LowLevelApi::class) - val opensavvy.ktmongo.dsl.path.Field.dayOfWeekIso: Value - get() = of(this).dayOfWeekIso + val opensavvy.ktmongo.dsl.path.Field.dayOfWeekISO: Value + get() = of(this).dayOfWeekISO /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3216,12 +3216,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3231,13 +3231,13 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/isoDayOfWeek/) */ @OptIn(LowLevelApi::class) - val kotlin.reflect.KProperty1.dayOfWeekIso: Value - get() = of(this).dayOfWeekIso + val kotlin.reflect.KProperty1.dayOfWeekISO: Value + get() = of(this).dayOfWeekISO /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3247,12 +3247,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3264,13 +3264,13 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @Suppress("INVISIBLE_REFERENCE") @OptIn(LowLevelApi::class) - val Instant.dayOfWeekIso: Value - get() = of(this).dayOfWeekIso + val Instant.dayOfWeekISO: Value + get() = of(this).dayOfWeekISO /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3280,12 +3280,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3296,14 +3296,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfObjectId") - final val Value.dayOfWeekIso: Value + @get:JvmName("dayOfWeekISOOfObjectId") + final val Value.dayOfWeekISO: Value get() = UnaryOperator(context, "isoDayOfWeek", this) /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3313,12 +3313,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3329,14 +3329,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfObjectId") - final val opensavvy.ktmongo.dsl.path.Field.dayOfWeekIso: Value - get() = of(this).dayOfWeekIso + @get:JvmName("dayOfWeekISOOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.dayOfWeekISO: Value + get() = of(this).dayOfWeekISO /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3346,12 +3346,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3362,14 +3362,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfObjectId") - final val kotlin.reflect.KProperty1.dayOfWeekIso: Value - get() = of(this).dayOfWeekIso + @get:JvmName("dayOfWeekISOOfObjectId") + final val kotlin.reflect.KProperty1.dayOfWeekISO: Value + get() = of(this).dayOfWeekISO /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3379,12 +3379,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3396,14 +3396,14 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfObjectId") - final val ObjectId.dayOfWeekIso: Value - get() = of(this).dayOfWeekIso + @get:JvmName("dayOfWeekISOOfObjectId") + final val ObjectId.dayOfWeekISO: Value + get() = of(this).dayOfWeekISO /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3413,12 +3413,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3429,14 +3429,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfTimestamp") - final val Value.dayOfWeekIso: Value + @get:JvmName("dayOfWeekISOOfTimestamp") + final val Value.dayOfWeekISO: Value get() = UnaryOperator(context, "isoDayOfWeek", this) /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3446,12 +3446,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3462,14 +3462,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfTimestamp") - final val opensavvy.ktmongo.dsl.path.Field.dayOfWeekIso: Value - get() = of(this).dayOfWeekIso + @get:JvmName("dayOfWeekISOOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.dayOfWeekISO: Value + get() = of(this).dayOfWeekISO /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3479,12 +3479,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3495,14 +3495,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfTimestamp") - final val kotlin.reflect.KProperty1.dayOfWeekIso: Value - get() = of(this).dayOfWeekIso + @get:JvmName("dayOfWeekISOOfTimestamp") + final val kotlin.reflect.KProperty1.dayOfWeekISO: Value + get() = of(this).dayOfWeekISO /** * 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]. + * To get the current week number, see [weekISO]. * * The accepted date types are [Instant], [ObjectId] and [Timestamp]. * @@ -3512,12 +3512,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeekIso: Int? = null, + * val birthdayOfWeekISO: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeekIso set User::birthdate.dayOfWeekIso + * User::birthdayOfWeekISO set User::birthdate.dayOfWeekISO * } * } * ``` @@ -3529,9 +3529,9 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekIsoOfTimestamp") - final val Timestamp.dayOfWeekIso: Value - get() = of(this).dayOfWeekIso + @get:JvmName("dayOfWeekISOOfTimestamp") + final val Timestamp.dayOfWeekISO: Value + get() = of(this).dayOfWeekISO // endregion // region $hour @@ -4281,7 +4281,7 @@ interface DateTimeValueOperators : ValueOperators { /** * 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]. + * 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]. * @@ -4291,12 +4291,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4306,13 +4306,13 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) */ @OptIn(LowLevelApi::class) - val Value.dayOfWeek: Value + val Value.dayOfWeekUS: Value get() = UnaryOperator(context, "dayOfWeek", this) /** * 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]. + * 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]. * @@ -4322,12 +4322,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4337,13 +4337,13 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) */ @OptIn(LowLevelApi::class) - val opensavvy.ktmongo.dsl.path.Field.dayOfWeek: Value - get() = of(this).dayOfWeek + val opensavvy.ktmongo.dsl.path.Field.dayOfWeekUS: Value + get() = of(this).dayOfWeekUS /** * 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]. + * 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]. * @@ -4353,12 +4353,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4368,13 +4368,13 @@ interface DateTimeValueOperators : ValueOperators { * - [Official documentation](https://www.mongodb.com/docs/manual/reference/operator/aggregation/dayOfWeek/) */ @OptIn(LowLevelApi::class) - val kotlin.reflect.KProperty1.dayOfWeek: Value - get() = of(this).dayOfWeek + val kotlin.reflect.KProperty1.dayOfWeekUS: Value + get() = of(this).dayOfWeekUS /** * 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]. + * 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]. * @@ -4384,12 +4384,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4401,13 +4401,13 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @Suppress("INVISIBLE_REFERENCE") @OptIn(LowLevelApi::class) - val Instant.dayOfWeek: Value - get() = of(this).dayOfWeek + val Instant.dayOfWeekUS: Value + get() = of(this).dayOfWeekUS /** * 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]. + * 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]. * @@ -4417,12 +4417,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4433,14 +4433,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfObjectId") - final val Value.dayOfWeek: Value + @get:JvmName("dayOfWeekUSOfObjectId") + final val Value.dayOfWeekUS: Value get() = UnaryOperator(context, "dayOfWeek", this) /** * 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]. + * 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]. * @@ -4450,12 +4450,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4466,14 +4466,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfObjectId") - final val opensavvy.ktmongo.dsl.path.Field.dayOfWeek: Value - get() = of(this).dayOfWeek + @get:JvmName("dayOfWeekUSOfObjectId") + final val opensavvy.ktmongo.dsl.path.Field.dayOfWeekUS: Value + get() = of(this).dayOfWeekUS /** * 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]. + * 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]. * @@ -4483,12 +4483,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4499,14 +4499,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfObjectId") - final val kotlin.reflect.KProperty1.dayOfWeek: Value - get() = of(this).dayOfWeek + @get:JvmName("dayOfWeekUSOfObjectId") + final val kotlin.reflect.KProperty1.dayOfWeekUS: Value + get() = of(this).dayOfWeekUS /** * 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]. + * 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]. * @@ -4516,12 +4516,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4533,14 +4533,14 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfObjectId") - final val ObjectId.dayOfWeek: Value - get() = of(this).dayOfWeek + @get:JvmName("dayOfWeekUSOfObjectId") + final val ObjectId.dayOfWeekUS: Value + get() = of(this).dayOfWeekUS /** * 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]. + * 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]. * @@ -4550,12 +4550,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4566,14 +4566,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfTimestamp") - final val Value.dayOfWeek: Value + @get:JvmName("dayOfWeekUSOfTimestamp") + final val Value.dayOfWeekUS: Value get() = UnaryOperator(context, "dayOfWeek", this) /** * 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]. + * 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]. * @@ -4583,12 +4583,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4599,14 +4599,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfTimestamp") - final val opensavvy.ktmongo.dsl.path.Field.dayOfWeek: Value - get() = of(this).dayOfWeek + @get:JvmName("dayOfWeekUSOfTimestamp") + final val opensavvy.ktmongo.dsl.path.Field.dayOfWeekUS: Value + get() = of(this).dayOfWeekUS /** * 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]. + * 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]. * @@ -4616,12 +4616,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4632,14 +4632,14 @@ interface DateTimeValueOperators : ValueOperators { */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfTimestamp") - final val kotlin.reflect.KProperty1.dayOfWeek: Value - get() = of(this).dayOfWeek + @get:JvmName("dayOfWeekUSOfTimestamp") + final val kotlin.reflect.KProperty1.dayOfWeekUS: Value + get() = of(this).dayOfWeekUS /** * 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]. + * 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]. * @@ -4649,12 +4649,12 @@ interface DateTimeValueOperators : ValueOperators { * class User( * val name: String, * val birthdate: Instant, - * val birthdayOfWeek: Int? = null, + * val birthdayOfWeekUS: Int? = null, * ) * * users.updateManyWithPipeline { * set { - * User::birthdayOfWeek set User::birthdate.dayOfWeek + * User::birthdayOfWeekUS set User::birthdate.dayOfWeekUS * } * } * ``` @@ -4666,9 +4666,9 @@ interface DateTimeValueOperators : ValueOperators { @kotlin.internal.LowPriorityInOverloadResolution @OptIn(LowLevelApi::class) @Suppress("INVISIBLE_REFERENCE", "WRONG_MODIFIER_CONTAINING_DECLARATION") - @get:JvmName("dayOfWeekOfTimestamp") - final val Timestamp.dayOfWeek: Value - get() = of(this).dayOfWeek + @get:JvmName("dayOfWeekUSOfTimestamp") + final val Timestamp.dayOfWeekUS: Value + get() = of(this).dayOfWeekUS // endregion diff --git a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt index 6eafc4c2..0464403c 100644 --- a/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt +++ b/dsl/src/commonTest/kotlin/aggregation/operators/DateTimeValueOperatorsTest.kt @@ -26,17 +26,17 @@ val DateTimeValueOperatorsTest by multiContextSuite { class Target( val date: Instant, val year: Int, - val week: Int, + val weekUS: Int, val second: Int, val month: Int, val minute: Int, val millisecond: Int, - val weekIso: Int, - val yearOfIsoWeek: Int, - val dayOfWeekIso: Int, + val weekISO: Int, + val yearOfISOWeek: Int, + val dayOfWeekISO: Int, val hour: Int, val dayOfMonth: Int, - val dayOfWeek: Int, + val dayOfWeekUS: Int, val dayOfYear: Int, ) @@ -61,13 +61,13 @@ val DateTimeValueOperatorsTest by multiContextSuite { test($$"$week") { TestPipeline() .set { - Target::week set Target::date.week + Target::weekUS set Target::date.weekUS } .shouldBeBson($$""" [ { "$set": { - "week": { + "weekUS": { "$week": "$date" } } @@ -151,13 +151,13 @@ val DateTimeValueOperatorsTest by multiContextSuite { test($$"$isoWeek") { TestPipeline() .set { - Target::weekIso set Target::date.weekIso + Target::weekISO set Target::date.weekISO } .shouldBeBson($$""" [ { "$set": { - "weekIso": { + "weekISO": { "$isoWeek": "$date" } } @@ -169,13 +169,13 @@ val DateTimeValueOperatorsTest by multiContextSuite { test($$"$isoWeekYear") { TestPipeline() .set { - Target::yearOfIsoWeek set Target::date.yearOfIsoWeek + Target::yearOfISOWeek set Target::date.yearOfISOWeek } .shouldBeBson($$""" [ { "$set": { - "yearOfIsoWeek": { + "yearOfISOWeek": { "$isoWeekYear": "$date" } } @@ -187,13 +187,13 @@ val DateTimeValueOperatorsTest by multiContextSuite { test($$"$isoDayOfWeek") { TestPipeline() .set { - Target::dayOfWeekIso set Target::date.dayOfWeekIso + Target::dayOfWeekISO set Target::date.dayOfWeekISO } .shouldBeBson($$""" [ { "$set": { - "dayOfWeekIso": { + "dayOfWeekISO": { "$isoDayOfWeek": "$date" } } @@ -241,13 +241,13 @@ val DateTimeValueOperatorsTest by multiContextSuite { test($$"$dayOfWeek") { TestPipeline() .set { - Target::dayOfWeek set Target::date.dayOfWeek + Target::dayOfWeekUS set Target::date.dayOfWeekUS } .shouldBeBson($$""" [ { "$set": { - "dayOfWeek": { + "dayOfWeekUS": { "$dayOfWeek": "$date" } } -- 2.51.2