Skip to content Skip to sidebar Skip to footer

Accessing Connected Vertices In Orientdb Javascript Functions

I'm attempting to use the build in Functions in OrientDB studio to group Workstations that aren't in use by a Person. The query to get these vertices works fine but I'm trying to a

Solution 1:

A simpler example to understand what you can do:

create class Person extends V    
create class IsNeighbour extends E

create vertex Person set name ='P1'//12:0create vertex Person set name ='P2'//12:1create vertex Person set name ='P3'//12:2create edge IsNeighbour from #12:0to #12:1create edge IsNeighbour from #12:0to #12:2

Define this Javascript Function:

var gdb = orient.getGraphNoTx();
var v = gdb.command("sql", "select from " + personRID);
var neighbours = v[0].getRecord().field("out_IsNeighbour").iterator();
var result = [];

while(neighbours.hasNext()){
  var neighbour = neighbours.next();
  result.push(neighbour.field("in"));
}

return result;

like this: enter image description here

And then you can:

selectgetNeighbours("#12:0")

Post a Comment for "Accessing Connected Vertices In Orientdb Javascript Functions"