Example:
@Entity(tableName = "data")
data class Data(@PrimaryKey(autoGenerate = true) val id: Int = 0,
@ColumnInfo(name = "blob") val blob: ByteArray,
@ColumnInfo(name = "timestamp", defaultValue = "(strftime('%s','now'))")
val timetamp: String)
How to create an instance of this class?
I want to create it like this:
Data(blob = byteArrayOf(1,2,3))
I have found a way for this example using default parameter values(updated declaration below), but for ordinary fields, I don't know how to specify a not nullable value which will be considered as no value: I have tried ColumnInfo.VALUE_UNSPECIFED
,"NULL"
,""
but no luck with it.
@Entity(tableName = "data")
data class Data(@PrimaryKey(autoGenerate = true) val id: Int = 0,
@ColumnInfo(name = "blob") val blob: ByteArray,
@ColumnInfo(name = "timestamp")
val timetamp: String = System.currentTimeMillis.toString())
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…