Due to a tcmalloc bug, MongoDB 8.x cannot run under the Linux kernel 6.19+.
Because our testing infrastructure runs under such a kernel, we are not able to continue testing the library with MongoDB 8.x.
We are not aware of any differences in MongoDB 8.x that could affect KtMongo.
Testing will MongoDB 8.x will restart once tcmalloc is fixed.
Follow this issue to learn more.
Additionally, we will no longer support MongoDB 6.x releases, as MongoDB themselves have stopped supporting it.
The kotlin.time.Instant has been stabilized in Kotlin 2.3.0. The @ExperimentalTime annotation has thus been removed from all methods that use it internally (!196)
The MongoDB official driver has two main serialization modes: :bson-kotlin (based on reflection) and :bson-kotlinx (based on KotlinX.Serialization). These two systems serialize objects slightly differently.
Most notably, the newly-added types kotlin.time.Instant and kotlin.uuid.Uuid are both serialized by :bson-kotlinx as strings, but are serialized to the corresponding BSON type by :bson-kotlin.
This release introduces the serializers InstantAsBsonDatetimeSerializer and UuidAsBsonBinarySerializer which use the BSON type no matter what serialization library is used, but also support JSON serialization as strings.
Users have to enable them explicitly (see their documentation to learn how).
In this version, we also ensured that the KtMongo types (ObjectId and Timestamp) are serialized correctly using both serialization strategies.
Since the start of the project, the configuration of BSON documents is stored by the BsonContext interface. However, it was starting to become too big.
Initially, BsonContext was used for BSON object creation. In 0.19.0, it obtained the capability of creating ObjectId instances. In this version, it would also have obtained the configuration for serializing paths.
In this release, it is changed as follows:
The BsonContext is removed from :bson.
The new BsonFactory interface becomes responsible from creating BSON documents.
The capability of creating new ObjectId instances remains in ObjectIdGenerator.
A new BsonContext interface is created in :dsl, which aggregates the capabilities required by the DSL.
If you created custom operators, you will need to switch the imports from the old BsonContext to the new one.
The new interface PropertyNameStrategy was added to configure how the Foo::user / User::name syntax is converted into MongoDB paths.
Users can override the default implementation when initializing the KtMongo library.
For example, this can be used to look up annotations on the fields to change their name.
When using one of the KMongo compatibility modules, the strategy used understands @BsonId and KotlinX.Serialization's @SerialName, as recommended by the KMongo documentation for the KotlinX.Serialization library.
If you use Jackson or want to use KotlinX.Serialization annotations with the regular driver modules (without using the KMongo compatibility modules) you can override the PropertyNameStrategy used by the driver.
We do not plan to add support for serialization annotations in the default implementation.
As a consequence, some methods have been moved from Field to FieldDsl.
Added the experimental BsonPath interface to represent JSONPath-like accessors to BSON documents.
BsonPath is a great alternative to deserialization when we are only interested in a few fields, as it avoids the need for creating complex DTOs, especially when they are deeply nested.
Instances of .reader() are now reused. This will make access to fields faster (60397c9d)
Added Bson.eager() and BsonArray.eager() to eagerly initialize the readers, which makes them thread-safe. Improved the documentation on thread-safety (!167)
Improved the documentation of Bson and BsonArray (!167)