简体   繁体   中英

How to write QueryBuilder Query to clean set or list value in Cassandra

Given a table:

CREATE TABLE User (
  id text,
  emails set<text>,
  PRIMARY KEY ((id))
)

How do I write the equivalent of the query below using QueryBuilder?

UPDATE User  SET emails = {} where id='xxx' 

By checking QueryBuilder class I found how to add/remove specific elements, and how to set a non-list, but not how to clear the list without specifying every element.

Setting to null apparently have the exact same result, so:

QueryBuilder.update("User")
 .where(QueryBuilder.eq("id","xxx"))
 .with(QueryBuilder.set("emails",null))

Did the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM