Newer
Older
MonCalc / app / src / main / kotlin / jackall / moncalc / db / RealmHelper.kt
package jackall.moncalc.db

import io.realm.Realm
import io.realm.RealmObject
import io.realm.RealmResults

/**
 * Created by matsumoto_k on 2017/11/02.
 */
abstract class RealmHelper<T : RealmObject> {
    protected val realm by lazy { Realm.getInstance(RealmConfig().config) }
    abstract fun insert(realmObject: T)
    abstract fun insert(realmObjects: List<T>)
    abstract fun update(realmObject: T)
    abstract fun update(realmObjects: List<T>)
    abstract fun findAll(): RealmResults<T>
    fun close() {
        realm.close()
    }
}