KV
07/20/2021, 12:26 PMResponse From Sever:
-------------------------------
[0] -> "abbreviation": null,
[1] -> "abbreviation": "abc"
---------------------------------
Response class:
---------------
@Serializable
data class Response(
val abbreviation: String, --------> here we should assume that abbreviation should never be null and if it is null then we need to setup the default value in the database.
val color: Int
)
I have a room database file
@Entity(tableName = "Employee")
class Employee(
@PrimaryKey(autoGenerate = false)
val id: String,
@ColumnInfo(defaultValue = "0000") val abbreviation: String, ------> setting the default value but in the databse it is still shows null because in the response I am getting null
val color: Int
) {
companion object {
fun fromDomain(employee: EmployeeData) = Employee(
id = employee.id,
pin = employee.abbreviation,
color = employee.color
)
}
fun toDomain() = EmployeeData(id,abbreviation,color)
}