NoteDao

interface NoteDao

Data Access Object (DAO) for the 'notes' table. This interface defines the database interactions (queries, inserts, updates, deletes) for Note entities. Room will generate the implementation for these methods. DAOs are the main way to interact with your app's persisted data.

Functions

Link copied to clipboard
abstract suspend fun deleteNote(note: Note)

Deletes a note from the 'notes' table. The note is identified by its primary key. This is a suspend function, designed for asynchronous execution.

Link copied to clipboard
abstract fun getActiveNotes(): Flow<List<Note>>

Retrieves all active (not soft-deleted) notes from the 'notes' table. Active notes are those where the 'isDeleted' flag is 0 (false). The results are ordered by timestamp in descending order (newest first).

Link copied to clipboard
abstract fun getAllNotes(): Flow<List<Note>>

Retrieves all notes from the 'notes' table, ordered by timestamp in descending order (newest first). This method returns a Flow of a list of notes. The Flow will automatically emit a new list whenever the data in the 'notes' table changes, allowing the UI to reactively update.

Link copied to clipboard
abstract fun getDeletedNotes(): Flow<List<Note>>

Retrieves all soft-deleted notes from the 'notes' table. Deleted notes are those where the 'isDeleted' flag is 1 (true). The results are ordered by timestamp in descending order (newest first).

Link copied to clipboard
abstract suspend fun insertNote(note: Note)

Inserts a new note into the 'notes' table. If a note with the same primary key already exists, it will be replaced due to onConflict = OnConflictStrategy.REPLACE. This is a suspend function, meaning it should be called from a coroutine or another suspend function to perform the operation asynchronously.

Link copied to clipboard
abstract suspend fun updateNote(note: Note)

Updates an existing note in the 'notes' table. The note is identified by its primary key. This is a suspend function, designed for asynchronous execution.