package kr.co.vividnext.sodalive.audio_content

import kr.co.vividnext.sodalive.common.ObjectBox

class PlaybackTrackingRepository(private val objectBox: ObjectBox) {
    fun savePlaybackTracking(data: PlaybackTracking): Long {
        return objectBox.playbackTrackingBox.put(data)
    }

    fun getPlaybackTracking(id: Long): PlaybackTracking? {
        val query = objectBox.playbackTrackingBox
            .query(PlaybackTracking_.id.equal(id))
            .build()

        val playbackTracking = query.findFirst()
        query.close()
        return playbackTracking
    }

    fun getAllPlaybackTracking(): List<PlaybackTracking> {
        return objectBox
            .playbackTrackingBox
            .all
    }

    fun removeAllPlaybackTracking() {
        objectBox.playbackTrackingBox.removeAll()
    }
}
