A Kotlin toolkit for Mongo
Questions tagged [kmongo]
48 questions
1
vote
1 answer
mongodb query: result with conditional find
I'm trying to do an conditional find in MongoDB.
Given a collection with the following fields:
itemId: Long
itemName: String
unconsumed: Boolean
snooze: Boolean
expiryTs: Long
I want to find all items depending on whether they are unconsumed,…

christian meyer
- 71
- 1
- 5
1
vote
0 answers
Group objects and then sort these groups using a single query
I need to implement a mongo query that forms 2 group depending if the avatarUrl is non null and then sorts these groups by lastName.
Here is how the collection looks like:
{
"lastName": "Bradley",
"avatarUrl": "http://...",
},
{
…

Baptiste Arnaud
- 2,522
- 3
- 25
- 55
0
votes
1 answer
How I can get ID of a new record in Kmongo
class MongoRepo(private val collection: MongoCollection) : Repo {
override fun create(element: E): Boolean {
collection.insertOne(element)
return true
}
override fun read(): List- > {
return…

Денис Попков
- 3
- 2
0
votes
0 answers
How to save Enum in Kmongo using Kotlin and Kotlin serialization
I tryna save Enum class in Kmongo, but I get error:
A String value cannot be written to the root level of a BSON document.
org.bson.BsonInvalidOperationException: A String value cannot be written to the root level of a BSON document.
Here is my code…

Денис Попков
- 3
- 2
0
votes
1 answer
KMongo and coroutines
I have a question related to coroutines and KMongo. I'm using KMongo CoroutineCollection to find some records in the database. On my local computer it takes <0.5sec but when I do the same thing on development environment it takes 10-25 seconds.
The…

bemol
- 381
- 3
- 18
0
votes
0 answers
How can I correctly convert a String to BinData type 3 in MongoDB? I can't perform a search on a field with a binData type using kotlin
I can't perform a search on a field with a binData type using Kotlin.
val queryFilter = Document("field1", "")
val result = insights.findOne( queryFilter)
return result

Duany Baró Menéndez
- 49
- 3
0
votes
0 answers
Kmongo relations
I am working on an API with Ktor and Kmongo that returns a list of posts and each one is written by a user so my model looks like this :
data class Post(
@BsonId val id: ObjectId,
@BsonId val userId: Id,
val content: String
)
data…

François Legrand
- 1,151
- 1
- 14
- 25
0
votes
2 answers
Kotlin error: "Invalid build configuration. Attempt to create a global synthetic for 'Record desugaring' without a global-synthetics consumer."
I am facing a small issue, where executing kmongo code in a simple kt file with a main() function, it works fine, but when I try to implement it in my SDK project by installing it and adding "implementation 'org.litote.kmongo:kmongo:4.8.0'" to the…
0
votes
0 answers
How to register custom kmongo codec in kotlin?
I want to create custom codec for DateTimePeriod...
open class DateTimePeriodCodec : Codec {
override fun getEncoderClass(): Class = DateTimePeriod::class.java
override fun encode(writer: BsonWriter, value:…
user15861750
0
votes
0 answers
efficienct improving on sorting
My code is here:
https://github.com/Dyfused/ExplodeX/blob/master/labyrinth-mongodb/src/main/kotlin/explode2/labyrinth/mongo/LabyrinthMongo.kt#L87,L259
document structures
Set example:
{
"musicName": "Ignotus Afterburn",
"musicComposer": "Arcaea…

Taskeren
- 35
- 3
0
votes
1 answer
Filter Query using KMongo
I want to filter out the courses on the basis of match query to the courseTitle.
So How can I perform this operation via **KMONGO **at server side ?
This is my Course Data Class
And I have a course document in MongoDB compass.
@Serializable
data…

Keval Kanpariya
- 11
- 3
0
votes
1 answer
BsonInvalidOperationException in ktor
Being new to MongoDB, I'm currently integrating the kMongo library to my ktor project, and trying to create a database to read & write event models to.
Following the instructions for object mapping in the kMongo user manual, I've created a mongoId…

ItWillDo
- 468
- 4
- 9
0
votes
0 answers
Euqivalent of Mongoose 'pre' with Kmongo
In my Mongo DB, I have a user ID and status fields. Before inserting a new record I've to check for some combination of these fields and insert a new record accordingly.
In NodeJS with Mongoose, 'pre' is a functionality where I can validate before…

Satyam
- 15,493
- 31
- 131
- 244
0
votes
0 answers
readDouble can only be called when CurrentBSONType is DOUBLE, not when CurrentBSONType is DECIMAL128
I'm trying out kmongo in my new spring boot application. With kmongo I'm using kotlin serialisation and getting an error when reading from db.
In DB, I've a Decimal128 field in my collection, I'm trying to deserialise it into a Double (or…

Drunken Daddy
- 7,326
- 14
- 70
- 104
0
votes
0 answers
MongoDB Nested Aggregation Issue
I'm trying to join some items from one collection to another. The original collection has nested arrays that I'm trying to join on from the other collection.
My data looks like this:
Feed
{
name: "feed name",
carousels: [
{
…

Vinnie
- 252
- 1
- 9