Skip to content

0.30.0 • 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:

Target::score set (of(2) * of(Target::score) * of(3))

After:

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:

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 (#76, !241)
  • For now, no operators use them. However, they are serializable.

Deployment

  • Apple x64 targets have been removed, because they are deprecated

Documentation


Browse the documentation for this versionView release in GitLab