I have a data class contains id and code.
And I have a List contains codes only.
how to insert the codes into table without making up ids?
Actually I do not need the id column at all, but it seems Room requires a primary key, and codes cannot be primary key.
Room:
@Entity(tableName = "raw_table")
data class Raw(
@PrimaryKey(autoGenerate = true)
var id: Long = 0L,
@ColumnInfo(name = "code")
var code: String = "",
...
List and loop:
val codeList : List<String> = ...
for (code in codeList){
// wrong here, I need the id, but I do not have ids.
RawDao.insert(code)
}