https://kotlinlang.org logo
Title
m

Mateusz Kolbusz

04/08/2023, 10:00 AM
Hi, I'm trying to set expiration date on field in my database with kmongo-coroutine driver. My goal is when date is expired whole entry should be removed rom mongo db. But idk how to make it work.
override suspend fun setTokenInvalid(refreshToken: String):Boolean {
    collection.createIndex(RefreshToken::refreshToken, IndexOptions().expireAfter(7, TimeUnit.DAYS))

}
I've found solution but in my opinion there is a better solution without using string.
collection.createIndex(
    " { expiresAt : 1 } ",
    IndexOptions().expireAfter(60, TimeUnit.SECONDS)
)
m

Marcin Wisniowski

04/17/2023, 10:09 AM
#kmongo