You could do this with a map instead of a list.

*CREATE TABLE movie (*
* id text,*
* name text,*
* ratings map<text, int>,*
* PRIMARY KEY ( id )*
*);*

*UPDATE movie SET ratings['bob'] = 5 WHERE id = 'terminator 3';*

--
Michael Mior
michael.m...@gmail.com

2016-10-24 18:16 GMT-04:00 Ali Akhtar <ali.rac...@gmail.com>:

> Say I have this UDT:
>
> *CREATE TYPE rating (*
> * user text,*
> * rating int*
> *);*
>
> And, I have this table:
>
> *CREATE TABLE movie (*
> * id text,*
> * name text,*
> * ratings list<FROZEN<rating>>,*
> * PRIMARY KEY ( id )*
> *);*
>
> Say a user 'bob' rated a movie as a 5. Is it possible to do something like
> this:
>
> *UPDATE movie set ratings.rating = 5 WHERE ratings.user = 'bob'*
>
> And have that query either update bob's previous rating if he had already
> rated, or have it insert a new Rating into the ratings w/ user = bob,
> rating = 5?
>
> If not, can this be achieved with a map instead of a list?
>
> Thanks.
>

Reply via email to