BSON refactor, type-aware operators and Multiplatform progress This is KtMongo's greatest release yet. It contains multiple breaking changes, though they should not impact users in major ways. ### The BSON refactor With the growth of the library, we have noticed that the design of the BSON classes was suboptimal. - `Bson` has been renamed to `BsonDocument` - `BsonValue` has been created - `BsonDocumentReader` has been removed (its functionality is now included directly in `BsonDocument`) - `BsonArrayReader` has been removed (its functionality is now included directly in `BsonArray`) - `BsonValueReader` has been removed (its functionality is now included directly in `BsonValue`) - All reading methods have been renamed to `encode` variants - The API to access data from `BsonDocument`, `BsonArray` and `BsonValue` has been rewritten, with conversion functions to `Map`, `List`, `Iterable` and `Sequence` - All implementations now throw the same `BsonDecodingException` on failure - We now test KtMongo against both the official's reflection-based and KotlinX.Serialization-based libraries - `BsonDocument`, `BsonArray` and `BsonValue` has a `factory` property to access the factory which created them (0fb55a77) - The types `BsonDocument`, `BsonArray` and `BsonValue` can now be serialized and deserialized, which is convenient for handling dynamic or untyped data (!238) Related changes in the official BSON implementation: - `BsonFactory` is changed from an `interface` to an `expect class` - Kotlin primitive types can now be serialized and deserialized without additional configuration (60a016ae) For more information, see #112 and !223. ### The operators refactor The KtMongo DSL now has a templating engine, which allows generating convenience overloads for most operators. In most situations, aggregation queries don't need the `of()` operator anymore. Before: ```kotlin Target::score set (of(2) * of(Target::score) * of(3)) ``` After: ```kotlin Target::score set (2 * Target::score * 3) ``` All operators now have an additional overload that accepts `KType` as a last parameter. These overloads are not meant to be called directly by users, you should almost always call the overload that doesn't have a `KType` parameter. Operators are now `inline reified`, which allows the serialization library to know about type parameters (which were previously stripped during compilation). This information is not yet used in all situations. Additionally: - The syntax of the [`switch` conditional aggregation operator](https://ktmongo.opensavvy.dev/api/dsl/opensavvy.ktmongo.dsl.aggregation.operators/-conditional-value-operators/index.html#switch) has changed: the value is now defined with `then` instead of `to` - The `addToSet` overload that accepts a list has been renamed to [`addEachToSet`](https://ktmongo.opensavvy.dev/api/dsl/opensavvy.ktmongo.dsl.query/-update-query/index.html#addeachtoset) - Added `Field.unsafeCast<T>()` (7a5170bd) - Added the [`$push` update operator](https://ktmongo.opensavvy.dev/api/dsl/opensavvy.ktmongo.dsl.query/-update-query/index.html#push) with its different options (!236) ### Route to Multiplatform - The entire DSL can now compile and run on KotlinJS in addition to the JVM (!239). More platforms are coming in the future. - The repository now contains a prototype Multiplatform driver (!240). ### GeoJSON - Added the seven GeoJSON data types under the [`Geo` interface](https://ktmongo.opensavvy.dev/api/bson/opensavvy.ktmongo.bson.types/-geo/index.html) (#76, !241) - For now, no operators use them. However, they are serializable. ### Deployment - Apple x64 targets have been removed, because they are deprecated ### Documentation - The tutorial pages now link directly to the API reference (624fb8c4) - Reworked the [Getting Started](https://ktmongo.opensavvy.dev/tutorials/index.html) page to mention the different KtMongo flavors (806fc7ed) - Added detailed pages on [KotlinX.Serialization](https://ktmongo.opensavvy.dev/tutorials/official/serialization-kotlinx.html), [Reflection](https://ktmongo.opensavvy.dev/tutorials/official/serialization-reflection.html) and [custom](https://ktmongo.opensavvy.dev/tutorials/official/serialization-custom.html) serialization strategies. - Java driver: fixed missing pages and incorrect examples (abfb3301, 6317e9ef)