News¶
0.25.0 • BsonContext/BsonFactory split, serialization annotation support, experimental BsonPath and eager multiplatform BSON
BsonContext and BsonFactory
Breaking change
Impacted modules:
:bson,:dsl
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
BsonContextis removed from:bson. - The new
BsonFactoryinterface becomes responsible from creating BSON documents. - The capability of creating new
ObjectIdinstances remains inObjectIdGenerator. - A new
BsonContextinterface 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.
Otherwise, end-users should not be impacted.
PropertyNameStrategy
Impacted modules:
:dsl,:driver-sync-kmongo,:driver-coroutines-kmongo
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.
BsonPath
Experimental
Impacted modules:
:bson
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.
BSON
- Removed
@ExperimentalStdlibApion theObjectIdconstructor as it has been stabilized in the standard library (b9ccf073) ObjectId.Serializerhas been changed from a class to an object (88f6947e)Timestamp.Serializerhas been changed from a class to an object (88f6947e)
BSON (multiplatform)
- Instances of
.reader()are now reused. This will make access to fields faster (60397c9d) - Added
Bson.eager()andBsonArray.eager()to eagerly initialize the readers, which makes them thread-safe. Improved the documentation on thread-safety (!167) - Improved the documentation of
BsonandBsonArray(!167)
Dependencies
- Kotlin 2.2.21
0.24.0 • Mokodee, unset shorthand and easier KMongo migration
DSL
Documentation
- Added Mokodee, the KtMongo mascot! (c488893f, thanks to Lilywhiteout)
- Added a set up guide to the KMongo migration guide (e663d70f)
- Reorganized and updated the Multiplatform roadmap (67f6816d, 716ce781)
- Formatting improvements in the aggregation page (20d455fa, 35c79cf4)
Dependencies
- Prepared 2.1.1
0.23.0 • Multiplatform KotlinX.Serialization, Field.unsafe expansion, replace and KMongo utilities
BSON (Multiplatform)
DSL
- Added
Field.unsafe()overloads to allow more use-cases (!132) $concatnow allows nullability, and has been moved fromArithmeticValueOperatorstoStringValueOperators(!134)
Drivers
- Added
replaceOne()andrepsertOne()(!133) - Added
:driver-sync-kmongoand:driver-coroutines-kmongowith a utility function to convert KMongo objects to KtMongo objects (!132)
Documentation
- Introduced the Kotlin Multiplatform roadmap (0861208a)
- Added a feature page on aggregations (f4bec354)
- Minor improvements on the home page
0.22.0 • WASI, averages and aggregation deserialization fixes
BSON
- Added Wasm WASI support (!126)
DSL
Drivers
0.21.0 • $group and string aggregation operators
DSL
- Projections are now represented with booleans instead of integers, for smaller request payloads (#81, !121)
Aggregation stages:
- Added
$group(!120)
Accumulation operators:
- Added
$sum(!120)
Aggregation operators:
- Added
$multiply,$divideand$subtract(!122) - Added
$trim,$ltrimand$rtrim(!123) - Added
$toLowerand$toUpper(!123) - Added
$substrCP,$substrBytes,$strLenCPand$strLenBytes(!123) - Added
$split(!123) - Added
$replaceOneand$replaceAll(!123)
Dependencies
- KotlinX.Serialization 1.9.0
- KotlinX.Coroutines 1.10.2
- KotlinX.IO 0.8.0
- MongoDB Java driver 5.5.1
0.20.0 • $addToSet, $currentDate and the new documentation website
BSON
- Added support for reading and writing
ObjectId(!110)
DSL
- Added support for the update operator
$addToSet(!107) - Added support for the update operator
$currentDate(!108)
Documentation
0.19.0 • Pure Kotlin ObjectId and Timestamp, $switch, type aggregation operators, bitwise filter operators, writeConcern and readPreference
BSON
- Moved
ObjectIdtoopensavvy.ktmongo.bson.types(6e455683, !80) - Added
ObjectIdGeneratorwith multiple implementations (!80) - Added
ObjectId.MINandObjectId.MAX(!80) - Added
BsonContext.newId(!80) - Added
BsonReader.readInstantandBsonWriter.writeInstant(244237ed, !88) - Added
opensavvy.ktmongo.bson.types.Timestamp(!89) - Changed timestamp APIs from
Longto the newTimestamptype (!89)
BSON (official)
- Deleted the old expect class opensavvy.ktmongo.bson.official.types.ObjectId (!80)
- Added a codec for the new ObjectId (!80)
BSON (multiplatform)
- Decreased data copying when reading data (417128b5, !84)
- Removed autoboxing in the implementation of the reader (17cab93a, !84)
- Added no-copy piping of BSON from a reader to a writer (!86)
- Added support for reading and writing
BsonType.DateTimeaskotlin.time.Instant(e15001f4, !88) - Added support for reading and writing
BsonType.RegExp(2bb5e544, !88) - Added support for reading and writing
BsonType.Timestamp(aa3c9a9e, !89)
Official driver
JvmMongoCollection.findnow returns aJvmMongoIterableinstead of aMongoIterable(!85)
DSL
- Added the aggregation operator
$switch(!90) - Added the aggregation operators
$type,$isArray,$isNumber,$toBoolean,$toDate,$toDouble,$toInt,$toLong,$toObjectId,$toStringand$toUUID(!91) - Added the filter operators
$bitAllClear,$bitsAllSet,$bitsAnyClearand$bitsAnySet(!92) - Added the option
writeConcern(!93) - Added the option
readPreference(!94) - Created the
Commandinterface and reorganized all commands to emit their BSON representation (!95)
Documentation
Dependencies
- Kotlin 2.2.0
0.18.0 • ObjectId, range operators, $min and $max, read concern and Java usage
BSON
DSL
- Added the
isInoperator to query on ranges (!75) - Added the
$sizefilter operator (659dae51, !82) - Added the
$norfilter operator (20378994, !82) - Added the
$minand$maxupdate operators (b298039f, !82) - Added the
readConcernoption (0b9520aa, !83)
Synchronous driver
- Added a new experimental module,
:driver-sync-java, with utilities for using KtMongo from Java (!69) - Java: Added
JavaField.of(Customer::name)syntax (!69) - Java: Added
KtMongo.from()helper (!69) - Java: Added
options(s -> s.)syntax (!69)
Dependencies
- Kotlin 2.1.21 (06afc477)
- MongoDB Java driver 5.5.0 (07106e25)
- KotlinX.Serialization 1.8.1 (399750c2)