Hello how to set the default value in the table wh...
# room
k
Hello how to set the default value in the table when we have null value from the response:
Copy code
Response 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
Copy code
@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)
}