2017-10-09 88 views
0

內的用戶類型我有這個表和用戶類型編輯地圖

CREATE TYPE IF NOT EXISTS criteria (
    id text, 
    enumerate text, 
    name text, 
    description text, 
); 

CREATE TYPE IF NOT EXISTS module (
    id text, 
    enumerate text, 
    name text, 
    description text, 
    criteria map<int, frozen<criteria>> 
); 

CREATE TABLE IF NOT EXISTS certification (
    id timeuuid, 
    owner text, 
    description text, 
    name text, 
    template map<int, frozen<module>>, 
    images map<text, text>, 
    PRIMARY KEY (id, owner) 
); 

如何更新或與標準的地圖添加新數據。

首先在模板字段

UPDATE certification set template = template + 
{1:{ 
    id: '***', 
    enumerate: '***', 
    name: 'aaa', 
    description: 'aaa', 
    criteria: {} 
}} 
where owner='***' and id = ***; 

後添加數據,我想更新的標準。我是想這個(認證表已有數據和模板字段映射鍵= 1):

UPDATE certification set 
template[1].criteria = template[1].criteria + 
       {1:{ 
        id: 'xxxx', 
        enumerate: 'xxxx', 
        name: 'xxxx', 
        description: 'xxxx' 
       }} 
where owner='****' and id = ***; 

template[1]['criteria']

,但我得到一個錯誤。

SyntaxException: line 2:27 mismatched input '.' expecting '=' 

回答

1

爲凍結的字段模板值定義,冷凍是不可改變的

不能更新凍結的項目,你有充分的價值重新插入。

凍結值將多個組件串行化爲單個值。非凍結類型允許更新到單個字段。 Cassandra將凍結類型的值視爲blob。整個值必須被覆蓋。

而且卡桑德拉不支持內收集非冷凍場

來源:https://docs.datastax.com/en/cql/3.1/cql/cql_reference/collection_type_r.html