Код: Выделить всё
MyModelКод: Выделить всё
deletedAtВот моя таблица:
Код: Выделить всё
@Entity(tableName = "my_table")
data class MyModel(
@PrimaryKey
@ColumnInfo(name = "id")
var id: String,
@ColumnInfo(name = "deletedAt")
var deletedAt: Date? = null
)
Код: Выделить всё
@Dao
abstract class MyDao : BaseDao {
@Query("SELECT * from my_table WHERE deletedAt IS NULL")
abstract fun getList(): LiveData
}
Код: Выделить всё
object DateTypeConverter {
@TypeConverter
@JvmStatic// It need to added else gives unwanted data binding error :D
fun fromTimestamp(value: Long?): Date? {
return if (value == null) null else Date(value)
}
@TypeConverter
@JvmStatic
fun dateToTimestamp(date: Date?): Long? {
return date?.time
}
Подробнее здесь: https://stackoverflow.com/questions/589 ... in-room-db