MeshLogDao

interface MeshLogDao(source)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract suspend fun deleteAll()
Link copied to clipboard
abstract suspend fun deleteLog(uuid: String)
Link copied to clipboard
abstract suspend fun deleteLogs(fromNum: Int, portNum: Int)
Link copied to clipboard
abstract suspend fun deleteLogsByUuid(uuids: List<String>)
Link copied to clipboard
open suspend fun deleteLogsByUuidAtomic(uuids: List<String>)

Atomically deletes all logs matching uuids, chunking internally to stay under SQLite's bind-parameter limit. The entire batch is all-or-nothing: a failure rolls back every chunk.

Link copied to clipboard
abstract suspend fun deleteOlderThan(cutoffTimestamp: Long, limit: Int): Int

Deletes at most limit logs received before cutoffTimestamp and returns how many it removed. Callers repeat it until it removes fewer than limit, so a retention pass never holds the write lock for the whole backlog.

Link copied to clipboard
abstract fun getAllLogs(maxItem: Int): Flow<List<MeshLog>>
Link copied to clipboard
abstract suspend fun getAllLogsSnapshot(): List<MeshLog>

Snapshot + IGNORE-insert used by DatabaseMerger to carry telemetry/position/traceroute history across transports. uuid is a unique string per row, so IGNORE is just belt-and-suspenders against a rare clash.

Link copied to clipboard
abstract fun getLatestOfType(type: String): Flow<MeshLog?>

The newest log of type, or null. Re-runs on every log write, so it reads one row through its index.

Link copied to clipboard
abstract fun getLogsFrom(fromNum: Int, portNum: Int, maxItem: Int): Flow<List<MeshLog>>

Retrieves MeshLogs matching 'from_num' (nodeNum) and 'port_num' (PortNum).

Link copied to clipboard
abstract fun getLogsFromPort(fromNum: Int, portNum: Int, maxItem: Int): Flow<List<MeshLog>>

getLogsFrom for one port. Without the any-port branch SQLite walks the (from_num, port_num, received_date) index newest first and stops at maxItem, with no sort.

Link copied to clipboard
abstract suspend fun getLogsInReceiveOrderAfter(afterReceivedDate: Long, afterRowId: Long, pageSize: Int): List<MeshLogRow>

Returns up to pageSize logs after (afterReceivedDate, afterRowId), oldest first. Equal received dates stay in rowid order, which is the order a scan of the received_date index returns. Start from Long.MIN_VALUE for both and continue from the last row returned.

Link copied to clipboard
abstract fun getLogsOnPort(portNum: Int, excludeFromNum: Int, maxItem: Int): Flow<List<MeshLog>>

Retrieves MeshLogs on 'port_num' (PortNum) from any node except excludeFromNum.

Link copied to clipboard
abstract suspend fun getLogsSnapshot(fromNum: Int, portNum: Int, maxItem: Int): List<MeshLog>

Suspend snapshot variant of getLogsFrom for one-shot reads (no Flow observer overhead). Used when a caller needs to read-then-process-then-delete in two steps — the selection requires Kotlin parsing so it stays outside the delete transaction, but the delete itself is atomic (see deleteLogsByUuidAtomic).

Link copied to clipboard
abstract suspend fun getLogsSnapshotPage(fromNum: Int, portNum: Int, beforeReceivedDate: Long?, beforeUuid: String?, pageSize: Int): List<MeshLog>

Returns one deterministic keyset page for bounded snapshot processing. beforeReceivedDate and beforeUuid identify the last row of the previous page; null values start from the newest row.

Link copied to clipboard
abstract suspend fun insert(log: MeshLog)
Link copied to clipboard
abstract suspend fun insertIgnore(logs: List<MeshLog>)