如何使用Room更新具有不同值的多个行的特定列?

时间:2019-07-09 02:47:08

标签: android kotlin android-room

说我有一个带有列的表“ cities_with_customers”

id | city       | customers
---+------------+----------
1  | London     | 5
2  | Bristol    | 6
3  | Birmingham | 7

和没有ID的地图

val map: mapOf("London" to 20, "Birmingham" to 5) // No ids!

现在我可以继续执行此操作

@Query("UPDATE cities_with_customers SET customers = :v WHERE city LIKE :k") }
fun update(k: String, v: Int)

for((k, v) in map) 
    dao.update(k,v) 

但是有没有一种方法可以将其优化为单个查询?

类似

@Query( **magic happens here!**)    
dao.update(cities: List<String>, customers: List<Int>)

0 个答案:

没有答案