Skip to content

Commit

Permalink
#397 | Add support doc for method getNoteById() in NotesDao.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
PatilShreyas committed Feb 16, 2022
1 parent 7cdf19c commit 8f945d6
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ import kotlinx.coroutines.flow.Flow
@Dao
interface NotesDao {

/**
* The return type of this method is nullable because internally it throws an error if
* entity doesn't exist.
*
* Official docs says
*
* * When the return type is Flow<T>, querying an empty table throws a null pointer exception.
* * When the return type is Flow<T?>, querying an empty table emits a null value.
* * When the return type is Flow<List<T>>, querying an empty table emits an empty list.
*
* Refer: https://developer.android.com/reference/androidx/room/Query
*/
@Query("SELECT * FROM notes WHERE noteId = :noteId")
fun getNoteById(noteId: String): Flow<NoteEntity?>

Expand Down

0 comments on commit 8f945d6

Please sign in to comment.