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] 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() - } -) -``` -- 2.51.2