如何在orientdb中更新嵌入文档中的字段

时间:2016-02-01 17:56:49

标签: orientdb

我需要一个orientdb sql查询来更新嵌入文档中的字段。 文件样本就像这样

[

    {"id":"fd8ij14uc","text":"Option 1","votes":[]},
    {"id":"t44d32z73","text":"Option 2","votes":[]},
    {"id":"spceth23q","text":"Option 3","votes":[]}

]

如何增加价值,如#12;#12:2'到"投票"其中" id":" fd8ij14uc"

1 个答案:

答案 0 :(得分:0)

我试过这个结构:

create class Vote
create property Vote.vote integer

create class MyDocument
create property MyDocument.id String
create property MyDocument.text String
create property MyDocument.votes Linklist Vote

create class MyClass
create property MyClass.myField Embedded MyDocument

insert into vote(vote) values (25),(30),(31)

enter image description here

insert into MyClass content{"myField": {"@type":"d", "@class": "MyDocument","id": "fd8ij14uc","text": "Option 1", "votes": []}}
insert into MyClass content{"myField": {"@type":"d", "@class": "MyDocument","id": "t44d32z73","text": "Option 2", "votes": []}}
insert into MyClass content{"myField": {"@type":"d", "@class": "MyDocument","id": "spceth23q","text": "Option 1", "votes": []}}

enter image description here

UPDATE MyClass set myField.votes=[#12:0] WHERE myField.id="fd8ij14uc"

enter image description here