假设我们在OrientDB(1.7)模式中有一个类Package,它应该包含一个嵌入的Versions列表。将带有类型列表的Package类型的文档插入OrientDB的SQL命令是什么?
假设在引入Versions之前插入Package的当前SQL语句如下所示:
INSERT INTO Package (id) values ("apackage")
答案 0 :(得分:1)
create class Version
create property Version.v string
create property Version.release string
create class Package
create property Package.id string
create property Package.versions embeddedlist Version
如果您的情况如上所述,我相信您所寻找的是:
insert into Package set id = "apackage", versions = [{"@type":"d","@class":"Version", "v":"1.0.1", "release":"monday"}]
# returns #13:0
如果您想添加新版本:
update #13:0 add versions = [{"@type":"d","@class":"Version", "v":"1.0.2", "release":"tuesday"}]