我有一个带有 jsonb 列的数据库表,该列有一个实体,带有嵌套的子实体。假设我们有:
SELECT jsonb_set('{"top": {"nested": {"leaf" : 1}}}', '{top,nested,leaf}', '2');
更新哪个作品就可以了top.nested.leaf
to 2.
但是如果我们想要处理多个字段怎么办,例如:
SELECT jsonb_set('{"top": {"nested": {"leaf" : 1}, "other_nested": {"paper": 0}}}', '[{top,nested,leaf}, {top,other_nested,paper}]', '[2, 2]');
上面的内容不起作用并说:
ERROR: malformed array literal: "[{top,nested,leaf}, {top,other_nested,paper}]"
LINE 1: ...": {"leaf" : 1}, "other_nested": {"paper": 0}}}', '[{top,nes...
^
DETAIL: "[" must introduce explicitly-specified array dimensions.
有任何想法吗?