Reputation: 9786
I have the following CQL3 table.
CREATE TABLE UserKarma (
user_id uuid,
sub_type text,
karma counter,
PRIMARY KEY(user_id, sub_type)
) WITH COMPACT STORAGE
How do I either insert or update (single query) a value and increase the counter? If the entry doesn't exist, since the counter is 0
by default, then all new records created with this upsert should be 1
.
Upvotes: 2
Views: 201
Reputation: 9786
I figured it out.
UPDATE UserKarma SET karma = karma + 1 where user_id = d9d9354a-32e9-46d7-a56c61e21b486ae3 and sub_type = 'test';
Upvotes: 2