Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/src/main/java/com/medmapper/v33001/dao/MedicineDAO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ interface MedicineDAO {

@Query("DELETE FROM Medicine")
suspend fun deleteAll()
}

@Delete
Comment thread
motakean marked this conversation as resolved.
suspend fun delete(medicine: Medicine)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using @query and deleteall, we can use a simple @delete and delete method to make the code more clear and concise.

Source: https://developer.android.com/training/data-storage/room/accessing-data

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This same suggestion appeared in a previously submitted code review.
When that occurs, only the first gets credit.

}
16 changes: 12 additions & 4 deletions app/src/main/java/com/medmapper/v33001/dto/Medicine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ package com.medmapper.v33001.dto
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey

/**
* A data class representing Medicine
*
* @property name; the name of the medicine
* @property strength; the strength of the medicine
* @property start_date; the date the patient started the medicine
* @property preciscription_length; how long the patient should take the medicine
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added kdoc documention to better help the functionality of the data class.
https://kotlinlang.org/docs/kotlin-doc.html#block-tags

*
*/
@Entity(tableName = "Medicine")
data class Medicine(
@PrimaryKey(autoGenerate = true) val medID: Int,
@ColumnInfo(name = "name") val name: String?,
@ColumnInfo(name = "strength") val strength: String?,
@ColumnInfo(name = "start date") val startDate: String?,
@ColumnInfo(name = "prescription length") val lengthInDays: Int
@ColumnInfo(name = "start_date") val startDate: String?,
@ColumnInfo(name = "prescription_length") val lengthInDays: Int
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's important to seperate the column names with a "_" inbetween.

source: https://developer.android.com/training/data-storage/room/defining-data

//,@ColumnInfo() val endDate: Date = startDate
)
)