diff --git a/bson/README.md b/bson/README.md index bd106a3d..6991af93 100644 --- a/bson/README.md +++ b/bson/README.md @@ -20,7 +20,7 @@ The module `:bson-tests` provides unit tests to verify any new BSON implementati Utilities and primitives to read and write BSON documents. -[`Bson`][opensavvy.ktmongo.bson.Bson] and [`BsonArray`][opensavvy.ktmongo.bson.BsonArray] respectively represent BSON documents and arrays. +[`BsonDocument`][opensavvy.ktmongo.bson.BsonDocument] and [`BsonArray`][opensavvy.ktmongo.bson.BsonArray] respectively represent BSON documents and arrays. [`BsonFactory`][opensavvy.ktmongo.bson.BsonFactory] is the entry point to create new BSON documents. diff --git a/bson/src/commonMain/kotlin/BsonFactory.kt b/bson/src/commonMain/kotlin/BsonFactory.kt index a8c6902f..c5423b1b 100644 --- a/bson/src/commonMain/kotlin/BsonFactory.kt +++ b/bson/src/commonMain/kotlin/BsonFactory.kt @@ -221,8 +221,6 @@ interface BsonFactory { /** * Instantiates a new [BSON array][BsonArray] by reading its [bytes] representation. - * - * The reverse operation is available as [BsonArray.toByteArray]. */ @LowLevelApi fun readArray(bytes: ByteArray): BsonArray -- 2.51.2 From b1a1e3fbba5e201788ae365e336d7dea2054a968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Thu, 13 Aug 2026 17:53:07 +0200 Subject: [PATCH 2/4] docs(driver): Fix broken links --- driver-api/src/commonMain/kotlin/MongoCollection.kt | 2 +- driver-coroutines/README.jvm.md | 3 +-- driver-coroutines/README.md | 4 ++-- .../kotlin/CoroutineMongoAggregationPipeline.kt | 1 + .../src/jvmMain/kotlin/CoroutineMongoDatabase.kt | 4 ++-- driver-sync-java/README.md | 4 ++-- driver-sync/README.jvm.md | 3 +-- driver-sync/README.md | 4 ++-- .../src/jvmMain/kotlin/SyncMongoAggregationPipeline.kt | 1 + driver-sync/src/jvmMain/kotlin/SyncMongoClient.kt | 2 +- driver-sync/src/jvmMain/kotlin/SyncMongoCollection.kt | 6 +++--- driver-sync/src/jvmMain/kotlin/SyncMongoDatabase.kt | 10 +++++----- driver-sync/src/jvmMain/kotlin/SyncMongoIterable.kt | 4 ++-- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/driver-api/src/commonMain/kotlin/MongoCollection.kt b/driver-api/src/commonMain/kotlin/MongoCollection.kt index 5e1731c1..1bced91b 100644 --- a/driver-api/src/commonMain/kotlin/MongoCollection.kt +++ b/driver-api/src/commonMain/kotlin/MongoCollection.kt @@ -91,7 +91,7 @@ interface MongoCollection : ObjectIdGenerator, /** * THe name of this collection. * - * The collection name must be unique within a single [database] (otherwise, the two instances refer to the same data). + * The collection name must be unique within a single [MongoDatabase] (otherwise, the two instances refer to the same data). * * - The name should begin with a letter or an underscore (`_`). * - The name cannot be empty. diff --git a/driver-coroutines/README.jvm.md b/driver-coroutines/README.jvm.md index f68120aa..188506fd 100644 --- a/driver-coroutines/README.jvm.md +++ b/driver-coroutines/README.jvm.md @@ -24,7 +24,6 @@ val database = client.getDatabase("my_project") val collection = database.getCollection("users").asKtMongo() ``` -Note the call to [`asKtMongo()`][opensavvy.ktmongo.coroutines.asKtMongo] which is the only difference from the official usage. -From then on, all methods from this driver are available on the `collection` variable: see [MongoCollection][opensavvy.ktmongo.coroutines.MongoCollection]. +Note the call to [`asKtMongo()`][opensavvy.ktmongo.coroutines.asKtMongo] which is the only difference from the official usage. From then on, all methods from this driver are available on the `collection` variable: see [CoroutineMongoCollection][opensavvy.ktmongo.coroutines.CoroutineMongoCollection]. This means you are able to use KtMongo DSLs within your existing repositories: simply convert into a KtMongo equivalent where you need KtMongo functionality. diff --git a/driver-coroutines/README.md b/driver-coroutines/README.md index e920eb78..6f9b1853 100644 --- a/driver-coroutines/README.md +++ b/driver-coroutines/README.md @@ -39,7 +39,7 @@ dependencies { ## Basic usage -Once you have obtained an instance of [MongoCollection][opensavvy.ktmongo.coroutines.MongoCollection] (see platform-specific instructions on how to do this), you can use it to access the database: +Once you have obtained an instance of [CoroutineMongoCollection][opensavvy.ktmongo.coroutines.CoroutineMongoCollection] (see platform-specific instructions on how to do this), you can use it to access the database: ```kotlin class User( @@ -62,7 +62,7 @@ collection.update( ) ``` -[Learn more about the available operations][opensavvy.ktmongo.coroutines.MongoCollection]. +[Learn more about the available operations][opensavvy.ktmongo.coroutines.CoroutineMongoCollection]. # Package opensavvy.ktmongo.coroutines diff --git a/driver-coroutines/src/jvmMain/kotlin/CoroutineMongoAggregationPipeline.kt b/driver-coroutines/src/jvmMain/kotlin/CoroutineMongoAggregationPipeline.kt index a26eb8bf..367f14c4 100644 --- a/driver-coroutines/src/jvmMain/kotlin/CoroutineMongoAggregationPipeline.kt +++ b/driver-coroutines/src/jvmMain/kotlin/CoroutineMongoAggregationPipeline.kt @@ -20,6 +20,7 @@ package opensavvy.ktmongo.coroutines import opensavvy.ktmongo.api.MongoAggregationPipeline +import opensavvy.ktmongo.api.MongoIterable import opensavvy.ktmongo.dsl.LowLevelApi import opensavvy.ktmongo.dsl.aggregation.AccumulationOperators import opensavvy.ktmongo.dsl.aggregation.AggregationOperators diff --git a/driver-coroutines/src/jvmMain/kotlin/CoroutineMongoDatabase.kt b/driver-coroutines/src/jvmMain/kotlin/CoroutineMongoDatabase.kt index ce74bb05..c4906e44 100644 --- a/driver-coroutines/src/jvmMain/kotlin/CoroutineMongoDatabase.kt +++ b/driver-coroutines/src/jvmMain/kotlin/CoroutineMongoDatabase.kt @@ -33,7 +33,7 @@ import kotlin.reflect.typeOf * * ### What is a database? * - * [Collections][MongoCollection] are grouped into databases to avoid name collisions. + * [Collections][CoroutineMongoCollection] are grouped into databases to avoid name collisions. * Databases are similar to Kotlin packages. * If multiple applications are deployed in the same MongoDB instance in their own database, * they can use the same collection names (e.g. `users`) without conflicts. @@ -63,7 +63,7 @@ interface CoroutineMongoDatabase : MongoDatabase { override fun collection(name: String, type: KType): CoroutineMongoCollection /** - * Creates a [MongoCollection] object. + * Creates a [CoroutineMongoCollection] object. * * This method is purely a client-side operation, it does nothing in the MongoDB server. * In MongoDB, databases and collections are created implicitly on the first insert. diff --git a/driver-sync-java/README.md b/driver-sync-java/README.md index a018c5d3..dfea6d13 100644 --- a/driver-sync-java/README.md +++ b/driver-sync-java/README.md @@ -42,7 +42,7 @@ dependencies { Start by creating a `com.mongodb.client.MongoCollection` instance by following the instructions from the official Java driver. -Use the method [`KtMongo.from`][opensavvy.ktmongo.sync.KtMongo.from] to convert it into a KtMongo collection. +Use the method [`KtMongo.from`][opensavvy.ktmongo.sync.java.KtMongo.from] to convert it into a KtMongo collection. Because Java doesn't provide optional parameters, and because Java and Kotlin lambdas are slightly different, we offer convenience methods. @@ -54,4 +54,4 @@ collection.find(options(), filter(filter -> { You can find more complex examples in the [test directory](https://gitlab.com/opensavvy/ktmongo/-/tree/main/driver-sync-java/src/test/java/opensavvy/ktmongo/sync?ref_type=heads). -Java doesn't support operator overloading, so the `User::profile / Profile::name` syntax isn't possible. It is replaced by the [`JavaField`][opensavvy.ktmongo.sync.JavaField] class, which provides similar functionality. +Java doesn't support operator overloading, so the `User::profile / Profile::name` syntax isn't possible. It is replaced by the [`JavaField`][opensavvy.ktmongo.sync.java.JavaField] class, which provides similar functionality. diff --git a/driver-sync/README.jvm.md b/driver-sync/README.jvm.md index 8f55aeff..d666e639 100644 --- a/driver-sync/README.jvm.md +++ b/driver-sync/README.jvm.md @@ -24,7 +24,6 @@ val database = client.getDatabase("my_project") val collection = database.getCollection("users").asKtMongo() ``` -Note the call to [`asKtMongo()`][opensavvy.ktmongo.sync.asKtMongo] which is the only difference from the official usage. -From then on, all methods from this driver are available on the `collection` variable: see [MongoCollection][opensavvy.ktmongo.sync.MongoCollection]. +Note the call to [`asKtMongo()`][opensavvy.ktmongo.sync.asKtMongo] which is the only difference from the official usage. From then on, all methods from this driver are available on the `collection` variable: see [SyncMongoCollection][opensavvy.ktmongo.sync.SyncMongoCollection]. This means you are able to use KtMongo DSLs within your existing repositories: simply convert into a KtMongo equivalent where you need KtMongo functionality. diff --git a/driver-sync/README.md b/driver-sync/README.md index 11622f36..972092f6 100644 --- a/driver-sync/README.md +++ b/driver-sync/README.md @@ -39,7 +39,7 @@ dependencies { ## Basic usage -Once you have obtained an instance of [MongoCollection][opensavvy.ktmongo.sync.MongoCollection] (see platform-specific instructions on how to do this), you can use it to access the database: +Once you have obtained an instance of [SyncMongoCollection][opensavvy.ktmongo.sync.SyncMongoCollection] (see platform-specific instructions on how to do this), you can use it to access the database: ```kotlin class User( @@ -62,7 +62,7 @@ collection.update( ) ``` -[Learn more about the available operations][opensavvy.ktmongo.sync.MongoCollection]. +[Learn more about the available operations][opensavvy.ktmongo.sync.SyncMongoCollection]. # Package opensavvy.ktmongo.sync diff --git a/driver-sync/src/jvmMain/kotlin/SyncMongoAggregationPipeline.kt b/driver-sync/src/jvmMain/kotlin/SyncMongoAggregationPipeline.kt index b4b80feb..d042bd57 100644 --- a/driver-sync/src/jvmMain/kotlin/SyncMongoAggregationPipeline.kt +++ b/driver-sync/src/jvmMain/kotlin/SyncMongoAggregationPipeline.kt @@ -28,6 +28,7 @@ import opensavvy.ktmongo.dsl.options.SortOptionDsl import opensavvy.ktmongo.dsl.path.Field import opensavvy.ktmongo.dsl.query.FilterQuery import opensavvy.ktmongo.sync.api.MongoAggregationPipeline +import opensavvy.ktmongo.sync.api.MongoIterable import kotlin.reflect.KProperty1 import kotlin.reflect.KType import kotlin.reflect.typeOf diff --git a/driver-sync/src/jvmMain/kotlin/SyncMongoClient.kt b/driver-sync/src/jvmMain/kotlin/SyncMongoClient.kt index 89c966a2..a6c53f28 100644 --- a/driver-sync/src/jvmMain/kotlin/SyncMongoClient.kt +++ b/driver-sync/src/jvmMain/kotlin/SyncMongoClient.kt @@ -58,7 +58,7 @@ import opensavvy.ktmongo.sync.api.MongoClient * } * ``` * - * @see asKtMongoLegacy Convert an existing instance from the official Kotlin driver. + * @see asKtMongo Convert an existing instance from the official Kotlin driver. */ interface SyncMongoClient : MongoClient { diff --git a/driver-sync/src/jvmMain/kotlin/SyncMongoCollection.kt b/driver-sync/src/jvmMain/kotlin/SyncMongoCollection.kt index 34e11762..c643d769 100644 --- a/driver-sync/src/jvmMain/kotlin/SyncMongoCollection.kt +++ b/driver-sync/src/jvmMain/kotlin/SyncMongoCollection.kt @@ -40,9 +40,9 @@ import opensavvy.ktmongo.sync.api.operations.UpdateOperations * - Kotlin collections, like [List] and [Set], the embed an arbitrary number of items. * - Polymorphism, for example with `sealed class`, to have different fields based on a discriminator. * - * To avoid name collisions, collections are grouped into [databases][MongoDatabase]. + * To avoid name collisions, collections are grouped into [databases][SyncMongoDatabase]. * - * To obtain a collection, see [MongoDatabase.collection]. + * To obtain a collection, see [SyncMongoDatabase.collection]. * * ### Size limit * @@ -59,7 +59,7 @@ import opensavvy.ktmongo.sync.api.operations.UpdateOperations * - [Official documentation](https://www.mongodb.com/docs/manual/core/databases-and-collections/) * - [Size limits](https://www.mongodb.com/docs/manual/reference/limits/#bson-documents) * - * @see asKtMongoLegacy Convert an existing instance from the official Kotlin driver. + * @see asKtMongo Convert an existing instance from the official Kotlin driver. */ interface SyncMongoCollection : MongoCollection { diff --git a/driver-sync/src/jvmMain/kotlin/SyncMongoDatabase.kt b/driver-sync/src/jvmMain/kotlin/SyncMongoDatabase.kt index b8daeff2..6cfa3766 100644 --- a/driver-sync/src/jvmMain/kotlin/SyncMongoDatabase.kt +++ b/driver-sync/src/jvmMain/kotlin/SyncMongoDatabase.kt @@ -32,7 +32,7 @@ import kotlin.reflect.typeOf * * ### What is a database? * - * [Collections][MongoCollection] are grouped into databases to avoid name collisions. + * [Collections][SyncMongoCollection] are grouped into databases to avoid name collisions. * Databases are similar to Kotlin packages. * If multiple applications are deployed in the same MongoDB instance in their own database, * they can use the same collection names (e.g. `users`) without conflicts. @@ -41,7 +41,7 @@ import kotlin.reflect.typeOf * * ### Access * - * To obtain a database, see [MongoClient.database]. + * To obtain a database, see [SyncMongoClient.database]. * * To obtain a collection, see [collection]. * @@ -49,7 +49,7 @@ import kotlin.reflect.typeOf * * - [Official documentation](https://www.mongodb.com/docs/manual/core/databases-and-collections/) * - * @see asKtMongoLegacy Convert an existing instance from the official Kotlin driver. + * @see asKtMongo Convert an existing instance from the official Kotlin driver. */ interface SyncMongoDatabase : MongoDatabase { @@ -62,12 +62,12 @@ interface SyncMongoDatabase : MongoDatabase { override fun collection(name: String, type: KType): SyncMongoCollection /** - * Creates a [MongoCollection] object. + * Creates a [SyncMongoCollection] object. * * This method is purely a client-side operation, it does nothing in the MongoDB server. * In MongoDB, databases and collections are created implicitly on the first insert. * - * For an example, see [MongoClient]. + * For an example, see [SyncMongoClient]. */ @OptIn(LowLevelApi::class) @Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION") diff --git a/driver-sync/src/jvmMain/kotlin/SyncMongoIterable.kt b/driver-sync/src/jvmMain/kotlin/SyncMongoIterable.kt index c9b0a875..9fbecedf 100644 --- a/driver-sync/src/jvmMain/kotlin/SyncMongoIterable.kt +++ b/driver-sync/src/jvmMain/kotlin/SyncMongoIterable.kt @@ -28,7 +28,7 @@ import com.mongodb.kotlin.client.FindIterable * The Coroutine client provides a coroutine-aware API which internally uses the * [official Kotlin driver](https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/). * - * This type wraps a [FindFlow] from the official driver. + * This type wraps a [FindIterable] from the official driver. * See also [SyncMongoAggregateIterable]. * * ### External resources @@ -50,7 +50,7 @@ interface SyncMongoFindIterable : opensavvy.ktmongo.sync.api.Mon * The Coroutine client provides a coroutine-aware API which internally uses the * [official Kotlin driver](https://www.mongodb.com/docs/drivers/kotlin/coroutine/current/). * - * This type wraps a [AggregateFlow] from the official driver. + * This type wraps an [AggregateIterable] from the official driver. * See also [SyncMongoFindIterable]. * * ### External resources -- 2.51.2 From c087659c1464205e3067eb94d53da610fa2ff5b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Thu, 13 Aug 2026 17:55:30 +0200 Subject: [PATCH 3/4] docs(dsl): Fix broken links --- .../src/commonMain/kotlin/aggregation/stages/Lookup.kt | 4 ++-- .../src/commonMain/kotlin/path/BsonPathConversions.kt | 2 +- dsl/README.md | 6 +++--- dsl/src/commonMain/kotlin/aggregation/stages/Lookup.kt | 4 ++-- dsl/src/commonMain/kotlin/path/BsonPathConversions.kt | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dsl-template/src/commonMain/kotlin/aggregation/stages/Lookup.kt b/dsl-template/src/commonMain/kotlin/aggregation/stages/Lookup.kt index b926c948..424238ae 100644 --- a/dsl-template/src/commonMain/kotlin/aggregation/stages/Lookup.kt +++ b/dsl-template/src/commonMain/kotlin/aggregation/stages/Lookup.kt @@ -42,8 +42,8 @@ interface HasLookup : Pipeline { * Performs an equality match join between this collection and another collection. * * For each document in this pipeline, matching documents from the foreign collection are appended - * into the new array field [into]. - * If [into] already has a value, it is overwritten. + * into the new array field [into][LookupStageOperators.into]. + * If [into][LookupStageOperators.into] already has a value, it is overwritten. * * ### Example * diff --git a/dsl-template/src/commonMain/kotlin/path/BsonPathConversions.kt b/dsl-template/src/commonMain/kotlin/path/BsonPathConversions.kt index d89235ed..c5bfc5e0 100644 --- a/dsl-template/src/commonMain/kotlin/path/BsonPathConversions.kt +++ b/dsl-template/src/commonMain/kotlin/path/BsonPathConversions.kt @@ -128,7 +128,7 @@ inline fun BsonDocument.selectFirst(field: Field<*, T>): T = selectFirst(field.toBsonPath()) /** - * Finds the first value that matches [path] in a given [BsonDocument]. + * Finds the first value that matches [field] in a given [BsonDocument]. * * ### Example * diff --git a/dsl/README.md b/dsl/README.md index a9e9975a..b3885b6a 100644 --- a/dsl/README.md +++ b/dsl/README.md @@ -87,7 +87,8 @@ users.aggregate() } .toList() ``` -To learn more about aggregation operators and their syntax, see [`ValueDsl`][opensavvy.ktmongo.dsl.aggregation.ValueDsl]. + +To learn more about aggregation operators and their syntax, see [`AggregationOperators`][opensavvy.ktmongo.dsl.aggregation.AggregationOperators]. You may also be interested in reading the [official documentation on aggregations](https://www.mongodb.com/docs/manual/aggregation/). @@ -100,8 +101,7 @@ All operators are declared as interface members. Each interface groups the opera - [FilterQuery][opensavvy.ktmongo.dsl.query.FilterQuery] is used in `find()`, `count()`, `delete()` and as the filter in `updateMany()` - [UpdateQuery][opensavvy.ktmongo.dsl.query.UpdateQuery] is used as the update in `updateMany()` - [UpsertQuery][opensavvy.ktmongo.dsl.query.UpsertQuery] is used as the update in `upsertOne()` -- [UpdateWithPipelineQuery][opensavvy.ktmongo.dsl.query.UpdateWithPipelineQuery] is used as the update in `updateManyWithPipeline()` -- [UpsertWithPipelineQuery][opensavvy.ktmongo.dsl.query.UpsertWithPipelineQuery] is used as the update in `upsertOneWithPipeline()` +- [UpdateWithPipelineQuery][opensavvy.ktmongo.dsl.query.UpdateWithPipelineQuery] is used as the update in `updateOneWithPipeline()` and similar # Package opensavvy.ktmongo.dsl.path diff --git a/dsl/src/commonMain/kotlin/aggregation/stages/Lookup.kt b/dsl/src/commonMain/kotlin/aggregation/stages/Lookup.kt index b97d2293..7f9620ff 100644 --- a/dsl/src/commonMain/kotlin/aggregation/stages/Lookup.kt +++ b/dsl/src/commonMain/kotlin/aggregation/stages/Lookup.kt @@ -45,8 +45,8 @@ interface HasLookup : Pipeline { * Performs an equality match join between this collection and another collection. * * For each document in this pipeline, matching documents from the foreign collection are appended - * into the new array field [into]. - * If [into] already has a value, it is overwritten. + * into the new array field [into][LookupStageOperators.into]. + * If [into][LookupStageOperators.into] already has a value, it is overwritten. * * ### Example * diff --git a/dsl/src/commonMain/kotlin/path/BsonPathConversions.kt b/dsl/src/commonMain/kotlin/path/BsonPathConversions.kt index 5e0655b6..ee829c9c 100644 --- a/dsl/src/commonMain/kotlin/path/BsonPathConversions.kt +++ b/dsl/src/commonMain/kotlin/path/BsonPathConversions.kt @@ -131,7 +131,7 @@ inline fun BsonDocument.selectFirst(field: Field<*, T>): T = selectFirst(field.toBsonPath()) /** - * Finds the first value that matches [path] in a given [BsonDocument]. + * Finds the first value that matches [field] in a given [BsonDocument]. * * ### Example * -- 2.51.2 From 4611bdb240fe96710f69cf6a7d4d7f4826690a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Thu, 13 Aug 2026 18:17:25 +0200 Subject: [PATCH 4/4] docs(website): Fix broken links --- docs/website/docs/features/bulk-writes.md | 6 +- docs/website/docs/features/crud.md | 25 +++--- .../docs/features/filtered-collections.md | 5 +- docs/website/docs/features/index.md | 2 +- .../docs/tutorials/from-kmongo/index.md | 4 +- .../docs/tutorials/from-kmongo/setup.md | 8 +- .../docs/tutorials/from-kmongo/update.md | 86 ------------------- 7 files changed, 24 insertions(+), 112 deletions(-) delete mode 100644 docs/website/docs/tutorials/from-kmongo/update.md diff --git a/docs/website/docs/features/bulk-writes.md b/docs/website/docs/features/bulk-writes.md index 46d559d5..239d2da6 100644 --- a/docs/website/docs/features/bulk-writes.md +++ b/docs/website/docs/features/bulk-writes.md @@ -18,7 +18,7 @@ for (user in usersToCreate) { This code is bad because each insert will send data to the database and wait for its response. Between each insert, it waits for the previous one to finish and for an entire network roundtrip. -Instead, we can insert all users at once with [`insertMany`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-insert-operations/index.md#insertmany): +Instead, we can insert all users at once with [`insertMany`](../api/driver-api/opensavvy.ktmongo.api.operations/-insert-operations/index.md#insertmany): ```kotlin val usersToCreate = listOf( @@ -32,9 +32,9 @@ users.insertMany(usersToCreate) Here, a single request is sent to the database, which can perform all inserts much quicker. -Similarly, other write operations have a variant that allows performing the same write on multiple documents: [`updateMany`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-update-operations/index.md#updatemany) and [`deleteMany`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-delete-operations/index.md#deletemany). +Similarly, other write operations have a variant that allows performing the same write on multiple documents: [`updateMany`](../api/driver-api/opensavvy.ktmongo.api.operations/-update-operations/index.md#updatemany) and [`deleteMany`](../api/driver-api/opensavvy.ktmongo.api.operations/-delete-operations/index.md#deletemany). -Sometimes, however, we want to perform very different writes, but we could still benefit from sending them all in a single request. In those situations, we can use [`bulkWrite`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-update-operations/index.md#bulkwrite): +Sometimes, however, we want to perform very different writes, but we could still benefit from sending them all in a single request. In those situations, we can use [`bulkWrite`](../api/driver-api/opensavvy.ktmongo.api.operations/-update-operations/index.md#bulkwrite): ```kotlin users.bulkWrite { diff --git a/docs/website/docs/features/crud.md b/docs/website/docs/features/crud.md index 4dbd8ba4..68fc478e 100644 --- a/docs/website/docs/features/crud.md +++ b/docs/website/docs/features/crud.md @@ -43,7 +43,7 @@ In the rest of this article, we assume you have [obtained a collection](../tutor ## Create -Creating a new document is done directly with an instance of the class and the method [`insertOne`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-insert-operations/index.md#insertone): +Creating a new document is done directly with an instance of the class and the method [`insertOne`](../api/driver-api/opensavvy.ktmongo.api.operations/-insert-operations/index.md#insertone): ```kotlin users.insertOne(User(ObjectId(), "Bob")) @@ -51,7 +51,7 @@ users.insertOne(User(ObjectId(), "Bob")) If the collection didn't yet exist, any write operation creates it. -If we want to insert multiple documents at the same time, we can use [`insertMany`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-insert-operations/index.md#insertmany): +If we want to insert multiple documents at the same time, we can use [`insertMany`](../api/driver-api/opensavvy.ktmongo.api.operations/-insert-operations/index.md#insertmany): ```kotlin users.insertMany( @@ -63,20 +63,19 @@ users.insertMany( ## Read -Read operations retrieve documents from a collection. -For example, we can [`count`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-count-operations/index.md#count) how many documents exist in a collection: +Read operations retrieve documents from a collection. For example, we can [`count`](../api/driver-api/opensavvy.ktmongo.api.operations/-count-operations/index.md#count) how many documents exist in a collection: ```kotlin users.count() ``` -Or, we can get all the documents using the [`find`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-find-operations/index.md#find) method: +Or, we can get all the documents using the [`find`](../api/driver-api/opensavvy.ktmongo.api.operations/-find-operations/index.md#find) method: ```kotlin users.find().toList() ``` -However, lists are in-memory data structures, and it may not be appropriate to query an entire collection into memory. Instead, we can stream the results using [`forEach`](../api/driver-coroutines/opensavvy.ktmongo.coroutines/-mongo-iterable/index.md#foreach): +However, lists are in-memory data structures, and it may not be appropriate to query an entire collection into memory. Instead, we can stream the results using [`forEach`](../api/driver-api/opensavvy.ktmongo.api/-mongo-iterable/index.md#foreach): ```kotlin users.find().forEach { println("Found a document: $it") } @@ -110,7 +109,7 @@ This syntax is typesafe: invalid requests (for example comparing against another [//]: # (TODO: add a link to the 'collation' option, whenever it is implemented) -If you are only interested in a single document, use [`findOne`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-find-operations/index.md#findone), which returns a nullable value instead of a list: +If you are only interested in a single document, use [`findOne`](../api/driver-api/opensavvy.ktmongo.api.operations/-find-operations/index.md#findone), which returns a nullable value instead of a list: ```kotlin users.findOne { @@ -127,7 +126,7 @@ Learn more: Update operations modify existing documents in a collection. -Similarly to search criteria, we can use infix operators to update some fields. To update all documents, use [`updateMany`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-update-operations/index.md#updatemany): +Similarly to search criteria, we can use infix operators to update some fields. To update all documents, use [`updateMany`](../api/driver-api/opensavvy.ktmongo.api.operations/-update-operations/index.md#updatemany): ```kotlin users.updateMany { @@ -147,9 +146,9 @@ users.updateMany( } ``` -If you only want to update a single document, use [`updateOne`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-update-operations/index.md#updateone) instead, which has the same syntax. +If you only want to update a single document, use [`updateOne`](../api/driver-api/opensavvy.ktmongo.api.operations/-update-operations/index.md#updateone) instead, which has the same syntax. -Finally, if you want to ensure that a specific document exists, and want to create it if it doesn't, use [`upsertOne`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-update-operations/index.md#upsertone). +Finally, if you want to ensure that a specific document exists, and want to create it if it doesn't, use [`upsertOne`](../api/driver-api/opensavvy.ktmongo.api.operations/-update-operations/index.md#upsertone). Learn more: @@ -161,7 +160,7 @@ Learn more: Delete operations remove documents from a collection. Delete operations accept a filter, just like `findOne` and `findMany`. -To delete one document, use [`deleteOne`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-delete-operations/index.md#deleteone): +To delete one document, use [`deleteOne`](../api/driver-api/opensavvy.ktmongo.api.operations/-delete-operations/index.md#deleteone): ```kotlin users.deleteOne { @@ -169,7 +168,7 @@ users.deleteOne { } ``` -To delete multiple documents, use [`deleteMany`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-delete-operations/index.md#deletemany): +To delete multiple documents, use [`deleteMany`](../api/driver-api/opensavvy.ktmongo.api.operations/-delete-operations/index.md#deletemany): ```kotlin users.deleteMany { @@ -177,7 +176,7 @@ users.deleteMany { } ``` -Additionally, to delete the entire collection, use [`drop`](../api/driver-coroutines/opensavvy.ktmongo.coroutines.operations/-collection-operations/index.md#drop): +Additionally, to delete the entire collection, use [`drop`](../api/driver-api/opensavvy.ktmongo.api.operations/-collection-operations/index.md#drop): ```kotlin users.drop() diff --git a/docs/website/docs/features/filtered-collections.md b/docs/website/docs/features/filtered-collections.md index 037fd4dd..77b1eb01 100644 --- a/docs/website/docs/features/filtered-collections.md +++ b/docs/website/docs/features/filtered-collections.md @@ -16,8 +16,7 @@ We can use [delete operations](crud.md#delete) to remove documents from a collec In all these situations, we want to hide documents and ensure no requests can impact them. The traditional approach is to have a shared BSON filter and remember to apply it to all operations. Using this approach, it is very easy to forget one request, creating hard to trace bugs. To alleviate this, KtMongo introduces filtered collections. -As an example, let's imagine a list of invoices. Users can trash invoices, but we cannot actually delete them because they may need to be inspected later. -We use the [`filter`](../api/driver-coroutines/opensavvy.ktmongo.coroutines/-mongo-collection/index.md#filter) method to create a filtered collection containing only "live" invoices: +As an example, let's imagine a list of invoices. Users can trash invoices, but we cannot actually delete them because they may need to be inspected later. We use the [`filter`](../api/driver-api/opensavvy.ktmongo.api/-mongo-collection/index.md#filter) method to create a filtered collection containing only "live" invoices: ```kotlin val allInvoices = database.getCollection("invoices").asKtMongo() val liveInvoices = allInvoices.filter { Invoice::isLive ne false } @@ -38,7 +37,7 @@ trashedInvoices.deleteMany { ``` !!! note "Implementation" - [`.filter {}`](../api/driver-coroutines/opensavvy.ktmongo.coroutines/-mongo-collection/index.md#filter) is implemented by combining the filter criteria with the command's own criteria using an [`$and`](../api/dsl/opensavvy.ktmongo.dsl.query/-filter-query/index.md#and) operator. +[`.filter {}`](../api/driver-api/opensavvy.ktmongo.api/-mongo-collection/index.md#filter) is implemented by combining the filter criteria with the command's own criteria using an [`$and`](../api/dsl/opensavvy.ktmongo.dsl.query/-filter-query/index.md#and) operator. ## Bulk writes diff --git a/docs/website/docs/features/index.md b/docs/website/docs/features/index.md index 6a13dee5..57e33d9d 100644 --- a/docs/website/docs/features/index.md +++ b/docs/website/docs/features/index.md @@ -13,6 +13,6 @@ To learn about the different KtMongo features, choose an article in the sidebar, Are you searching for something in particular? - **BSON**: [Arbitrary values](../api/bson/opensavvy.ktmongo.bson/-bson-factory/index.md) • [Data types](../api/bson/opensavvy.ktmongo.bson.types/index.md) -- **Commands**: [Blocking](../api/driver-sync/opensavvy.ktmongo.sync/-jvm-mongo-collection/index.md) • [Coroutines](../api/driver-coroutines/opensavvy.ktmongo.coroutines/-jvm-mongo-collection/index.md) +- **Collection commands**: [API](../api/driver-api/opensavvy.ktmongo.api/-mongo-collection/index.md#operations) • [Blocking](../api/driver-sync/opensavvy.ktmongo.sync/-sync-mongo-collection/index.md) • [Coroutines](../api/driver-coroutines/opensavvy.ktmongo.coroutines/-coroutine-mongo-collection/index.md) - **Queries**: [Introduction](crud.md) • [Filter](../api/dsl/opensavvy.ktmongo.dsl.query/-filter-query/index.md#operators) • [Update](../api/dsl/opensavvy.ktmongo.dsl.query/-update-query/index.md#operators) • [Options](../api/dsl/opensavvy.ktmongo.dsl.options/-options/index.md) - **Aggregation**: [Introduction](aggregations.md) • [Stages](../api/dsl/opensavvy.ktmongo.dsl.aggregation/-pipeline/index.md#stages) • [Operators](../api/dsl/opensavvy.ktmongo.dsl.aggregation/-aggregation-operators/index.md#operators) • [Update](../api/dsl/opensavvy.ktmongo.dsl.query/-update-with-pipeline-query/index.md) • [Accumulators](../api/dsl/opensavvy.ktmongo.dsl.aggregation/-accumulation-operators/index.md#operators) diff --git a/docs/website/docs/tutorials/from-kmongo/index.md b/docs/website/docs/tutorials/from-kmongo/index.md index f56530b7..fe84ea80 100644 --- a/docs/website/docs/tutorials/from-kmongo/index.md +++ b/docs/website/docs/tutorials/from-kmongo/index.md @@ -47,14 +47,14 @@ KtMongo and KMongo are compatible, meaning that both can be used in the same pro === "Without coroutines" - Add the dependency ([list of versions](../../news)): + Add the dependency ([list of versions](../../news/index.md)): ```kotlin implementation("dev.opensavvy.ktmongo:driver-sync-kmongo:VERSION") ``` === "With coroutines" - Add the dependency ([list of versions](../../news)): + Add the dependency ([list of versions](../../news/index.md)): ```kotlin implementation("dev.opensavvy.ktmongo:driver-coroutines-kmongo:VERSION") ``` diff --git a/docs/website/docs/tutorials/from-kmongo/setup.md b/docs/website/docs/tutorials/from-kmongo/setup.md index 137779c6..739ae01a 100644 --- a/docs/website/docs/tutorials/from-kmongo/setup.md +++ b/docs/website/docs/tutorials/from-kmongo/setup.md @@ -13,21 +13,21 @@ KtMongo and KMongo are compatible, meaning that both can be used in the same pro === "Without coroutines" - Add the dependency ([list of versions](../../news)): + Add the dependency ([list of versions](../../news/index.md)): ```kotlin implementation("dev.opensavvy.ktmongo:driver-sync-kmongo:VERSION") ``` - This will add the [`MongoCollection.asKtMongo()`](../../api/driver-sync-kmongo/opensavvy.ktmongo.sync.kmongo/as-kt-mongo.md) extension function which converts from a KMongo `MongoCollection` to a KtMongo [`JvmMongoCollection`](../../api/driver-sync/opensavvy.ktmongo.sync/-jvm-mongo-collection/index.md). + This will add the [`MongoCollection.asKtMongo()`](../../api/driver-sync-kmongo/opensavvy.ktmongo.sync.kmongo/as-kt-mongo.md) extension function which converts from a KMongo `MongoCollection` to a KtMongo [`SyncMongoCollection`](../../api/driver-sync/opensavvy.ktmongo.sync/-sync-mongo-collection/index.md). === "With coroutines" - Add the dependency ([list of versions](../../news)): + Add the dependency ([list of versions](../../news/index.md)): ```kotlin implementation("dev.opensavvy.ktmongo:driver-coroutines-kmongo:VERSION") ``` - This will add the [`MongoCollection.asKtMongo()`](../../api/driver-coroutines-kmongo/opensavvy.ktmongo.coroutines.kmongo/as-kt-mongo.md) extension function which converts from a KMongo `MongoCollection` to a KtMongo [`JvmMongoCollection`](../../api/driver-coroutines/opensavvy.ktmongo.coroutines/-jvm-mongo-collection/index.md). + This will add the [`MongoCollection.asKtMongo()`](../../api/driver-coroutines-kmongo/opensavvy.ktmongo.coroutines.kmongo/as-kt-mongo.md) extension function which converts from a KMongo `MongoCollection` to a KtMongo [`CoroutineMongoCollection`](../../api/driver-coroutines/opensavvy.ktmongo.coroutines/-coroutine-mongo-collection/index.md). ## Serialization diff --git a/docs/website/docs/tutorials/from-kmongo/update.md b/docs/website/docs/tutorials/from-kmongo/update.md deleted file mode 100644 index 87308e07..00000000 --- a/docs/website/docs/tutorials/from-kmongo/update.md +++ /dev/null @@ -1,86 +0,0 @@ -# Converting your KMongo updates to KtMongo - -Much like [find variants](find.md), update operations use a DSL instead of passing raw BSON values. - -## Updating multiple documents - -Like with KMongo, the function to update multiple documents is `updateMany`. - -```kotlin title="With KMongo" -collection.updateMany( - filter = and( - User::name.exists(), - User::age gt 18 - ), - set( - User::isLegal setTo true - ) -) -``` - -```kotlin title="With KtMongo" -collection.updateMany( - filter = { - User::name.exists() - User::age gt 18 - }, - update = { - User::isLegal set true - } -) -``` - -To learn more about filtering, visit [the find documentation](find.md). - -Unlike in KMongo, there is no need to combine multiple operators yourself, the library will do it for you. The order of operators is not relevant. - -```kotlin title="With KMongo" -collection.updateMany( - filter = …, - set( - User::name setTo "foo", - User::isLegal setTo true, - ), - inc( - User::age setTo 1 - ) -) -``` - -```kotlin title="With KtMongo" -collection.updateMany( - filter = { … }, - update = { - User::name set "foo" - User::isLegal set true - User::age inc 1 - } -) -``` - -## Updating a single document - -Like in KMongo, KtMongo provides a dedicated function to edit a single element, `updateOne`. - -## Inserting a document if it doesn't exist - -KtMongo provides an overload to perform upserts: - -```kotlin title="With KMongo" -collection.updateOne( - filter = …, - setOnInsert( - User::creationDate setTo Instant.now(), - ), - UpdateOptions().upsert(true) -) -``` - -```kotlin title="With KtMongo" -collection.upsertOne( - filter = { … }, - update = { - User::creationDate setOnInsert Instant.now() - } -) -```