jvmMain.com.caesarealabs.loggy.jvm.LoggyMongodb.kt Maven / Gradle / Ivy
The newest version!
package com.caesarealabs.loggy.jvm
import com.caesarealabs.loggy.shared.DailyLogStat
import com.caesarealabs.loggy.shared.Invocation
import com.caesarealabs.rpc4k.runtime.jvm.user.components.mongo.MongoDb
/**
* Shares the collections used both during insertion (with :lib) and querying (with :service) of the mongo db
*/
class LoggyMongodb(private val mongoDb: MongoDb) {
private val db by lazy { mongoDb.getOrCreateClient().getDatabase("loggy") }
/**
* Caution! Do not reference until the moment you have to, to avoid doing a lot of extra work when you don't need to.
*/
val logsCollection by lazy { db.getCollection("logs") }
/**
* Caution! Do not reference until the moment you have to, to avoid doing a lot of extra work when you don't need to.
*/
val deletedLogStats by lazy { db.getCollection("deleted_stats") }
}