0

大家好(再次),我正在尝试加入 orient db 的两个班级。结果,我想要两个类的所有记录和属性。由于这里加入不起作用,所以请在 orientdb 中建议我如何加入,并请建议我如何在 orientdb 中使用边加入

4

1 回答 1

1

它相当简单:将目标记录的删除写入主表中的一个字段。

我将描述使用 activeorient,ruby-orientDB ORM:

 DB.create_class :basiswert
 => Basiswert 

 DB.create_class :stock
 => Stock 

 apple = Basiswert.create name: 'Apple', kind: 'silicon valley company'
 => #<Basiswert:0x0000000241ca38 @metadata={"type"=>"d", "class"=>"basiswert", "version"=>1, "fieldTypes"=>nil, "cluster"=>53, "record"=>0}, @d=nil, @attributes={"name"=>"Apple", "kind"=>"silicon valley company", "created_at"=>Fri, 24 Feb 2017 16:55:37 +0100}> 
apple_stock =  Stock.create symbol: 'AAPL', :price => 200, basiswert: apple
 => #<Stock:0x00000003ecb370 @metadata={"type"=>"d", "class"=>"stock", "version"=>1, "fieldTypes"=>"basiswert=x", "cluster"=>57, "record"=>0}, @d=nil, @attributes={"symbol"=>"AAPL", "price"=>200, "basiswert"=>"#53:0", "created_at"=>Fri, 24 Feb 2017 16:55:43 +0100}> 
apple_stock.basiswert
 => #<Basiswert:0x0000000241ca38 @metadata={"type"=>"d", "class"=>"basiswert", "version"=>1, "fieldTypes"=>nil, "cluster"=>53, "record"=>0}, @d=nil, @attributes={"name"=>"Apple", "kind"=>"silicon valley company", "created_at"=>Fri, 24 Feb 2017 16:55:37 +0100}> 

或者,您只需将“#53:0”放入»apple-stock.basiswert«

这是一个单向连接(或简单链接)。显然你可以查询stock-class

Stock.where basiswert: apple-stock.rid

或者在普通的 OrientDB-SQL 中

select from stock where basiswert= "#53:0"
于 2017-02-24T16:19:00.550 回答