use map or list types in cequel

226 Views Asked by At

I'm trying to define a Box class in Rails 5 with Cassandra and Cequel. is there a way to define a column with the map type.

something like this

create table Box ( id int PRIMARY KEY, coordinates Map<text, int>)

is there a way to do this with Cequel in rails? ideally something like

class Box
    include Cequel::Record
    column :coordinates, :map

or if there are some other more preferred way of storing coordinates or list information feel free to recommend.

1

There are 1 best solutions below

0
On

For a regular type like text or string you'd do:

column :name, :text

For a map - Cassandra needs to know the datatype for the key and value you are going to insert. Try:

map :coordinates, :<key_type>, :<val_type>