-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update quarkus and Kotlin versions. Migrate away from kmongo. Code cl…
…eanup
- Loading branch information
1 parent
4b1ff39
commit 7c57def
Showing
90 changed files
with
596 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 14 additions & 7 deletions
21
...stence/src/main/kotlin/net/adoptium/api/v3/dataSources/persitence/mongo/MongoInterface.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
package net.adoptium.api.v3.dataSources.persitence.mongo | ||
|
||
import com.mongodb.MongoCommandException | ||
import com.mongodb.kotlin.client.coroutine.MongoCollection | ||
import com.mongodb.kotlin.client.coroutine.MongoDatabase | ||
import kotlinx.coroutines.runBlocking | ||
import org.litote.kmongo.coroutine.CoroutineCollection | ||
import org.litote.kmongo.coroutine.CoroutineDatabase | ||
|
||
abstract class MongoInterface { | ||
|
||
inline fun <reified T : Any> createCollection(database: CoroutineDatabase, collectionName: String): CoroutineCollection<T> { | ||
return runBlocking { | ||
if (!database.listCollectionNames().contains(collectionName)) { | ||
// TODO add indexes | ||
inline fun <reified T : Any> createCollection(database: MongoDatabase, collectionName: String): MongoCollection<T> { | ||
runBlocking { | ||
try { | ||
database.createCollection(collectionName) | ||
} catch (e: MongoCommandException) { | ||
if (e.errorCode == 48) { | ||
// collection already exists ... ignore | ||
} else { | ||
throw e | ||
} | ||
} | ||
return@runBlocking database.getCollection<T>(collectionName) | ||
} | ||
return database.getCollection(collectionName, T::class.java) | ||
|
||
} | ||
} |
Oops, something went wrong.