A Kotlin toolkit for Mongo
Questions tagged [kmongo]
48 questions
4
votes
1 answer
Join multiple collections in MongoDB
Greetings amigo i have one question related joining multiple collection in MongoDb
i have collection schema something like below
Posts Collection
{
"type": "POST_TYPE",
"_id": "63241dffb0f6770c23663230",
"user_id":…

Bhushan Maniyar
- 121
- 6
4
votes
0 answers
Unit tests for Ktor with KMongo
How to make unit tests in Ktor with KMongo? How to mock database and make test on it? Let's say that I made simplest API like this:
private val client = KMongo.createClient().coroutine
private val database = client.getDatabase("dbName")
val people =…

ktorOneQuestion
- 41
- 2
3
votes
1 answer
Does KMongo support enums?
I have a mongo collection in which there is a String field called role. This field in particular will always be filled with one of these three options: user, admin or guest.
This is the reason why I decided to create an enum so it makes it easier…

Ignacio Rodríguez Suárez
- 103
- 1
- 9
3
votes
1 answer
How to configure object mapping for MongoDB with Micronaut and Kotlin + KMongo?
I'm having some difficulty configuring object mapping for MongoDB in Micronaut with Kotlin. I'm getting errors like:
Decoding into a 'Asset' failed with the following exception:
Cannot find a public constructor for 'Asset'.
A custom Codec or…

Jeroen Knoef
- 275
- 1
- 2
- 11
2
votes
1 answer
Kotlin KMongo library nested query not working
If nested property query is using, this is always returning null, I have no ideas why, just following offcial website document document link
database.getCollection().findOne(User::auth / Auth::ssaid eq p.ssaid, User::auth / Auth::password eq…

user16799920
- 27
- 5
2
votes
0 answers
Using Ktor, Kmongo and kotlinx.serialization together causing ClassCastException ... What am I doing wrong?
https://github.com/reticent-monolith/winds_server is the github repo if anyone finds it easier looking there.
I'm trying to use KMongo and Ktor with Kotlin's Serialization module but creating the MongoClient results in the following…

Reticent_Monolith
- 21
- 2
2
votes
0 answers
how to write Mongo type query with Kotlin sealed class
I want to access Mongo DB using Kotlin with the help of Kmongo (litote.org) plugins
and I only want to write Kmong Typed query. https://litote.org/kmongo/typed-queries/
My Kotlin data classes are below:
data class Student(
studentId:ObjectId,
…

shriyash Lakhe
- 607
- 1
- 9
- 21
2
votes
1 answer
KMongo queries producing different results from Mongo Shell
I'm currently using KMongo and it's very nice. Simple to use, nice syntax, etc.
But I ran into an issue while querying some data that I cannot figure it out. I'm filtering for some fields and when I run my queries on Mongo Shell or robo 3T it works…

Fabiano
- 1,344
- 9
- 24
2
votes
1 answer
Ktor with Kmongo and kotlinx.serialization
I have a setup where I use KTor with KMongo and Kotlinx.Serialization.
The Kmongo part works, I can get and put my Class
@Serializable
data class Task(@ContextualSerialization @SerialName("_id") val _id : Id = newId(),
val…

moortuvivens
- 63
- 6
1
vote
0 answers
How to correctly serialize an mongoDB ObjectId with kotlinx
I am trying to serialize a MongoDB ObjectId using a Kotlin, Spring Boot, KMongo and Kotlinx.
The problem is, that the ObjectId is getting serialized as timestamp:
Expected Result:
{"name":"Game…

EyedPeas
- 146
- 4
- 17
1
vote
1 answer
KMongo custom serializer: readEndDocument can only be called when State is END_OF_DOCUMENT, not when State is VALUE
I'm trying to make a custom serializer for the Color class using the kmongo-coroutine-serialization dependency.
I'm getting an exception when doing it saying:
Exception in thread "main" org.bson.BsonInvalidOperationException: readEndDocument can…

Marian
- 44
- 1
- 7
1
vote
1 answer
How to implement Pagination with Ktor and Kmongo
Problem:
To Implement Pagination on the server side using Ktor and Kmongo.
Tech Stacks:
Kotlin as Programming Language.
Ktor as Web Framework.
MongoDb as database.
Kmongo as Sql framework.
I cannot find any tutorial or posts that describes to…

Adi
- 61
- 10
1
vote
1 answer
How to use GRIDFSBuckets with KMongo coroutine client
I am trying to use GRIDFSBuckets in ktor to upload files. I am using KMongo coroutine extension to create my MongoDB client. When calling GRIDFSBucket.create(). Its parameters need a MongoDatabase and bucketName. This is fine but KMongo coroutines…

EmmaneulO1
- 63
- 1
- 5
1
vote
2 answers
MongoDB Database is not created in Kotlin(Ktor)
please i need help with connecting a mongodb to my ktor application.
This is the code i have, as followed from this article: https://himanshoe.com/mongodb-in-ktor
class MongoDataHandler {
val client = KMongo.createClient().coroutine
val database =…

Solomon Tolu Samuel
- 27
- 6
1
vote
2 answers
Delegate issue with Mongo and Kotlin
I've recently been using Kmongo library and Kotlin together however I've made an issue on Kmongo but I'm unsure it is related to the library.
I'm trying to persist my data onto my mongo database (version 4.2.2)
@Serializable
data class Person(val…

Biscuit
- 4,840
- 4
- 26
- 54