diff --git a/driver-sync/src/commonMain/kotlin/FilteredCollection.kt b/driver-sync/src/commonMain/kotlin/FilteredCollection.kt --- a/driver-sync/src/commonMain/kotlin/FilteredCollection.kt +++ b/driver-sync/src/commonMain/kotlin/FilteredCollection.kt @@ -16,6 +16,7 @@ package opensavvy.ktmongo.sync +import opensavvy.ktmongo.bson.types.ObjectId import opensavvy.ktmongo.dsl.BsonContext import opensavvy.ktmongo.dsl.LowLevelApi import opensavvy.ktmongo.dsl.command.* @@ -259,6 +260,9 @@ return "$upstream.filter $filter" } + + override fun newId(): ObjectId = + upstream.newId() } /** diff --git a/driver-sync/src/commonMain/kotlin/MongoCollection.kt b/driver-sync/src/commonMain/kotlin/MongoCollection.kt --- a/driver-sync/src/commonMain/kotlin/MongoCollection.kt +++ b/driver-sync/src/commonMain/kotlin/MongoCollection.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024-2025, OpenSavvy and contributors. + * Copyright (c) 2024-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. @@ -16,6 +16,7 @@ package opensavvy.ktmongo.sync +import opensavvy.ktmongo.bson.types.ObjectIdGenerator import opensavvy.ktmongo.sync.operations.* /** @@ -44,6 +45,7 @@ * - [Official documentation](https://www.mongodb.com/docs/manual/tutorial/query-documents) */ interface MongoCollection : + ObjectIdGenerator, FindOperations, CountOperations, UpdateOperations, diff --git a/driver-sync/src/jvmMain/kotlin/JvmMongoCollection.kt b/driver-sync/src/jvmMain/kotlin/JvmMongoCollection.kt --- a/driver-sync/src/jvmMain/kotlin/JvmMongoCollection.kt +++ b/driver-sync/src/jvmMain/kotlin/JvmMongoCollection.kt @@ -22,6 +22,7 @@ import opensavvy.ktmongo.bson.BsonValueReader import opensavvy.ktmongo.bson.official.JvmBsonFactory import opensavvy.ktmongo.bson.official.types.Jvm +import opensavvy.ktmongo.bson.types.ObjectId import opensavvy.ktmongo.bson.types.ObjectIdGenerator import opensavvy.ktmongo.dsl.LowLevelApi import opensavvy.ktmongo.dsl.aggregation.PipelineChainLink @@ -71,6 +72,10 @@ @OptIn(LowLevelApi::class) private val inner = inner.withCodecRegistry(context.codecRegistry) + + @OptIn(LowLevelApi::class) + override fun newId(): ObjectId = + context.newId() // region Find