1

I have a Cassandra 1.2 Column Family which looks like this:

food: 'steak'
value: 10
desserts: ['chocolate cake','banana pie','strawberry icecream']

And I need to delete one the desserts from this row , for instance 'chocolate cake' but if the list of desserts result in an empty list after removing one of the items I need to delete the entire row, is there a way to achieve this in a single query in Cassandra? If not, what's the best way to do it?

More info: the query I'm using to remove one of the items in the list is this:

update Table
set desserts = desserts - ['chocolate cake']
where food = 'steak'

Thanks in advance!

4

2 回答 2

2

从列表中删除元素的一行语句:

DELETE desserts[1] FROM table WHERE where food = 'steak';

作为参考,以下链接中的第 6 点来自 datastax: http ://docs.datastax.com/en/cql/3.0/cql/cql_using/use_list_t.html

此链接详细讨论了 cassandra 中使用的列表类型。

于 2016-04-01T05:34:13.530 回答
1

cassandra 尚不支持 Collection 框架上的这种高级功能。现在我猜你必须执行两个查询才能完成操作。

于 2013-05-11T04:20:02.057 回答