0

I just prepared a model which contains two vertices and one edge between them, v1, v2 and e1, while v1 is instance or vertex of class A, and v2 is vertex of class B. e1 is the instance of class E. I wanted to prepare schema in waterline for this kind of relation and the schema looks like this:

identity:'A',
connection:'ex1',
attributes:{
  title:'string',
  r : {collection:'B', through:'E', via:'A'}
}
identity:'A',
connection:'ex1',
attributes:{
  title:'string',
  r : {collection:'A', through:'E', via:'B'}
}

while if I use this schema to map into orientdb my fields it shows collection:'B' as a Linkset in A class. I just want to relate them via edges. Is there a way to skip mentioning collections and just build a relation which will map @rid of edge e1 into OUT or IN field of these classes as needed?

4

1 回答 1

0

xeeB,您没有提及您正在使用的 OrientDB 水线适配器(至少有 3 个)。我假设它是waterline-orientdb

在您的模式示例中,您正在定义“多对多通过”关联,但您缺少(或未共享)“通过”模型(示例)的定义。

最后,使用边在顶点之间建立关系的最简单方法是使用“多对多”关联。您可以根据自己的示例使用以下代码片段来执行此操作:

// Model A
{
  tableName : 'A',
  identity : 'a',
  connection : 'ex1',
  attributes : {
    title : 'string',
    r : {
      collection : 'b',
      via : 'r',
      dominant : true
    }
  }
}
// Model B
{
  tableName : 'B',
  identity : 'b',
  connection : 'ex1',
  attributes : {
    title : 'string',
    r : {
      collection : 'a',
      via : 'r'
    }
  }
}

完整的“多对多”关联工作示例: https ://github.com/appscot/waterline-orientdb/blob/master/example/associations/many-to-many.js

更新: waterline-orientdb 现在被命名为sails-orientdb。

于 2015-03-17T14:57:16.163 回答