I've started using Cequel in a project and I can't figure out how to work the Counters table. I have the following definition:
class Counter
include Cequel::Record
key :user_id, :text
column :text, :counter
column :int, :counter
column :boolean, :counter
column :timestamp, :counter
column :tag, :counter
end
and it creates the table properly:
>> DESCRIBE counters ;
CREATE TABLE counters (
user_id text PRIMARY KEY,
visits counter,
tweets counter
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
But when I try to create a record in the console I get:
INSERT statements are not allowed on counter tables, use UPDATE instead
I can see in the tests that there is a way to increment but I can't find the right syntax. Anyone has experience setting this up and can point me in the right direction?
Thanks!
Couldn't find a different solution than the
Metal
way like in the tests. Posting here for others to use or if someone has a better solution.