Hi,
you can create the function connect() with the parameters folderRid and 
fileName

var g=orient.getGraph();
var b=g.command("sql","select from folder where @rid = " + folderRid);
if(b.length>0){  
  var c=g.command("sql","select expand(out('contain')[name='"+fileName+"']) 
from folder where @rid = " + folderRid);
  if(c.length>0){ 
  return c[0]; 
  }
  else{  
      var d=g.command("sql","insert into file(name) values('"+fileName+"')"
); 
      g.commit();
    var file=g.command("sql","create edge contain from "+folderRid+" to "+d.
getId());
      g.commit();
      return d;
    }
}

and you can use this query from studio 

select expand(connect(12:0,"myFile.txt")) from (select connect())

Kind regards,
Alessandro

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to