Welcome everyone! It is time for me to start showi...
# kmongo
c
Welcome everyone! It is time for me to start showing what I've been working on for the past 6 months. As you know, KMongo has been deprecated after the release of the official Kotlin driver. However, many projects haven't migrated to the official driver, since it lacks most of the syntax that made KMongo enjoyable in the first place. KtMongo (cat-mongo) takes inspiration from the ideas behind KMongo, but rethinks everything from the bottom up, based on the official Kotlin driver. Based on our 4+ years of experience using KMongo in production, we have discovered many common patterns that are verbose to write or are easy to mess up. For these patterns, we have added (or are planning to add) new alternative options to avoid these issues. Let's take a look at a few requests:
Copy code
users.find {
    User::pets / Pet::name eq "Bob"
}
As you can see, a DSL replaces the parenthesis, but the syntax is almost identical.
Copy code
measurements.upsertOne(
    filter = {
        Measurement::room eq 5
        Measurement::storey eq 2
    },
    update = {
        Measurement::creationDate setOnInsert Instant.now()
        Measurement::lastModifiedDate set Instant.now()
        Measurement::value inc 12
    }
)
The DSL vastly simplifies syntax: no need to remember to group update operators, no need to specify
and
when multiple filters are specified—and we can finally use a regular
if
inside requests to create complex queries without making the code complex itself. Currently, KtMongo has released its 0.4.0 version. It isn't stable yet, and won't be for a while, but it is ready for feedback and early tests. Currently, it supports: • insertOne, insertMany • updateOne, updateMany, upsertOne • bulkWrite • find • count • drop as well as the operators: • $eq, $gt, $gte, $in, $lt, $lte, $ne, $and, $not, $or, $exists, $type, $all, $elemMatch • $inc, $rename, $set, $setOnInsert, $unset, $.0. Want to learn more reasons why to migrate when the library becomes stable? Visit our website. We plan on adding documentation pages on gradual migration (migrating from KMongo to KtMongo one-file-at-a-time, without a big-bang migration). Join us to discuss the project in #C078Z1QRHL3 , we're excited to see how far we can push Kotlin and MongoDB!
👍 2
m
Just seen this, looks like a great and viable path forward from KMongo! Thank you for your work.
c
Don't hesitate to join #C078Z1QRHL3 where I announce new things! And don't hesitate to help prioritize operators/features
👍 1