Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OrientDB嵌套JSON插入_Orientdb - Fatal编程技术网

OrientDB嵌套JSON插入

OrientDB嵌套JSON插入,orientdb,Orientdb,我有一个OrientDB问题。为了声明 INSERT INTO Account CONTENT { name : 'Luca', vehicles : { @class : 'Vehicle', type : 'Car', model : 'Maserati', isItTrue: false } } 我得到一个结果(见屏幕截图),但类/表“Vehicle”不包含任何条目。这是一个有效的结果吗? 我希望自动将一些值写入“Vehicle”并连接

我有一个OrientDB问题。为了声明

INSERT INTO Account CONTENT 
{ name : 'Luca',
  vehicles : {
     @class : 'Vehicle',
     type : 'Car',
     model : 'Maserati',
     isItTrue: false
  }
 }
我得到一个结果(见屏幕截图),但类/表“Vehicle”不包含任何条目。这是一个有效的结果吗? 我希望自动将一些值写入“Vehicle”并连接到“Account”。只有“帐户”中的“车辆”列包含JSON数据

谢谢你的回复

致意 卡罗


通过查询,您正在将嵌入数据插入帐户,如果您想将一些数据插入帐户和车辆,您应该在不同的查询中进行,然后如果您想将它们与边缘连接起来。见示例:

create class Account extends v
create class Vehicle extends v
create class owns extends e

create property Account.name String
create property Vehicle.type String
create property Vehicle.model String
create property Vehicle.isItTrue BOOLEAN

insert into Account(name) values ("Luca")
insert into Vehicle(type, model, isItTrue) values ("Car", "Maserati", false)

create edge owns from (select from Account where name = "Luca") to (select from Vehicle where model = "Maserati")

通过查询,您正在将嵌入数据插入帐户,如果您想将一些数据插入帐户和车辆,您应该在不同的查询中进行,然后如果您想将它们与边缘连接起来。见示例:

create class Account extends v
create class Vehicle extends v
create class owns extends e

create property Account.name String
create property Vehicle.type String
create property Vehicle.model String
create property Vehicle.isItTrue BOOLEAN

insert into Account(name) values ("Luca")
insert into Vehicle(type, model, isItTrue) values ("Car", "Maserati", false)

create edge owns from (select from Account where name = "Luca") to (select from Vehicle where model = "Maserati")

或者,如果您不想创建边,而只想从一个文档链接到另一个文档,下面的内容将在单次插入/事务中为您提供所需的结果,同时仍保留链接记录的json结构

 create class Account
 create class Vehicle
 create property Account.vehicles embedded Vehicle

 INSERT INTO Account set name = "luca", vehicles = [ {
     "@type": "d",
     "@class" : "Vehicle",
     "type" : "Car",
     "model" : "Maserati",
     "isItTrue": false
  }]

或者,如果您不想创建边,而只想从一个文档链接到另一个文档,下面的内容将在单次插入/事务中为您提供所需的结果,同时仍保留链接记录的json结构

 create class Account
 create class Vehicle
 create property Account.vehicles embedded Vehicle

 INSERT INTO Account set name = "luca", vehicles = [ {
     "@type": "d",
     "@class" : "Vehicle",
     "type" : "Car",
     "model" : "Maserati",
     "isItTrue": false
  }]