Reputation: 3
I have 2 vertex classes - EMPLOYEE and BRANCH which are both populated with data and I want an edge class InBranch to be their relationship.
So Employee -InBranch-> Branch.
Class Employee with properties -> empname, branchname.
Class Branch with propety --> branchname.
Instead of a common property (branchname) as relationship,
I would like to make these as edges (InBranch).
I'm trying to make work a construct similar to below:
CREATE EDGE InBranch FROM (SELECT FROM Employee) TO (SELECT FROM Branch) WHERE Employee.branchname = Branch.branchname
which is intuitively patterned after Luca Garulli's code :
create edge Owns from (select from Person) to (select from Country)
from OrientDB: Using Schemas with Graphs, Part 1.
Upvotes: 0
Views: 96
Reputation: 1982
you can't do it directly via sql, but you can use a JS function:
var g = orient.getGraph();
var emp = g.command('sql','select from Employee');
for each (a in emp){
br = g.command('sql','select from Branch where branchname = "' + a.getProperty('branchname') + '"');
for each (b in br){
g.command('sql','create edge inBranch from ' + a.getId() + ' to ' + b.getId());
}
}
Upvotes: 1