我需要得到类似的东西:
Map<String, Boolean>
或List<Pair>
Dao:
...
@Query("SELECT id, isFavorite FROM sources")
fun getCompareData(): Map<String, Boolean>
...
Entitiy:
@Entity(tableName = "sources")
data class Source(
@PrimaryKey val id: String,
val name: String,
val description: String,
val language: String,
val country: String,
var isFavorite: Boolean = false
)
或者我该怎么做?
更新:我刚刚创建
data class Favorite(
val id: String,
val isFavorite: Boolean
)
并写成`fun getFavorites():列表