我正在使用幻影 1.26.6。
// id is the primary key
case class Motorcycle(id:String, model:String, made:String, capacity:Int)
给一个已存在于 Cassandra 中的 Motorcycle 实例,我想更新模型、制造、容量的值。
// The following does not compile.
update.where(_.id.eqs(bike.id)).modify(_.model.setTo(bike.model))
.modify(_.make.setTo(bike.make))
.modify(_.capacity.setTo(bike.capacity))
// The following works.
val updateQuery = update.where(_.id.eqs(bike.id))
for {
_ <- updateQuery.modify(_.model.setTo(bike.model)).future()
_ <- updateQuery.modify(_.make.setTo(bike.made)).future()
result <- updateQuery.modify(_.capacity.setTo(bike.capacity)).future()
} yield (result)
我想知道是否有更好的方法来更新多个字段。
提前感谢您的帮助!
盛