编辑地图
问题描述:
内的用户类型我有这个表和用户类型编辑地图
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 '='
答
为冻结的字段模板值定义,冷冻是不可改变的
不能更新冻结的项目,你有充分的价值重新插入。
冻结值将多个组件串行化为单个值。非冻结类型允许更新到单个字段。 Cassandra将冻结类型的值视为blob。整个值必须被覆盖。
而且卡桑德拉不支持内收集非冷冻场
来源:https://docs.datastax.com/en/cql/3.1/cql/cql_reference/collection_type_r.html