我需要一个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"
答案 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)
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": []}}
UPDATE MyClass set myField.votes=[#12:0] WHERE myField.id="fd8ij14uc"