AuditDao

Data Access Object for audit trail operations.

Provides CRUD operations for audit events and chain state management.

Functions

Link copied to clipboard
abstract suspend fun countEvents(): Long

Count total events.

Link copied to clipboard
abstract suspend fun countEventsInRange(fromTs: Long, toTs: Long): Long

Count events in a time range.

Link copied to clipboard
abstract suspend fun deleteAllEvents()

Delete all events.

Link copied to clipboard
abstract suspend fun deleteEventsBefore(beforeTs: Long): Int

Delete events older than a timestamp.

Link copied to clipboard
abstract suspend fun deleteEventsByUserId(userId: String): Int

Delete all events for a specific user.

Link copied to clipboard
abstract suspend fun getAllEvents(): List<AuditEventEntity>

Get all events ordered by timestamp.

Link copied to clipboard
abstract suspend fun getChainState(): AuditChainState?

Get chain state.

Link copied to clipboard
abstract suspend fun getEventById(id: String): AuditEventEntity?

Get an event by ID.

Link copied to clipboard
abstract suspend fun getEventNameCounts(): List<EventNameCount>

Get distinct event names with counts.

Link copied to clipboard
abstract suspend fun getEventsByName(name: String): List<AuditEventEntity>

Get events by name.

Link copied to clipboard
abstract suspend fun getEventsByUserId(userId: String): List<AuditEventEntity>

Get all events for a specific user.

Link copied to clipboard
abstract suspend fun getEventsForVerification(fromTs: Long, toTs: Long): List<AuditEventEntity>

Get events for chain verification in order.

Link copied to clipboard
abstract suspend fun getEventsInRange(fromTs: Long, toTs: Long): List<AuditEventEntity>

Get events in a time range, ordered by timestamp.

Link copied to clipboard
abstract suspend fun getLatestEvent(): AuditEventEntity?

Get the most recent event.

Link copied to clipboard
abstract suspend fun getOldestEvent(): AuditEventEntity?

Get the oldest event.

Link copied to clipboard
abstract suspend fun insertEvent(event: AuditEventEntity)

Insert a new audit event.

Link copied to clipboard

Atomic insert of event and chain state update.

Link copied to clipboard
abstract suspend fun upsertChainState(state: AuditChainState)

Insert or update chain state.