I tried your example with a simple DB of two classes:
- Bill (extends V) with the property billDate as datetime;
- nextBill (extends E).
with this query
create vertex Bill set billDate=sysdate(), in_nextBill=(select @rid from Bill where billDate in (select max(billDate) from Bill))
you can at the same time create the bill and the edge referred to the previous.
EDITED
I created a Javascript Function that removes the edge between two records and inserts a new record (with relative edges) between the previous two.
The function accepts three input parameters:
* date1: datetime format
;
* date2: datetime format
;
* newBillDate: datetime format
is the date of new bill you want to insert between the previous two ;
var g=orient.getGraph();
var d1=g.command('sql','select from Bill where billDate in "'+date1+'"');
var d2=g.command('sql','select from Bill where billDate in "'+date2+'"');
var startDate=d1[0];
var endDate=d2[0];
if(endDate.getRecord().field("billDate").getTime()<startDate.getRecord().field("billDate").getTime()){
var temp=endDate;
endDate=startDate;
startDate=temp;
}
var selectEdge=g.command('sql','select from nextBill where in='+endDate.getId()+' and out='+startDate.getId());
g.command('sql','delete edge '+selectEdge[0].getId());
var newIns=g.command('sql','create vertex Bill set billDate="'+newBillDate+'"');
g.commit();
g.command('sql','create edge nextBill from '+startDate.getRecord().getIdentity()+' to '+newIns.getRecord().getIdentity());
g.command('sql','create edge nextBill from '+newIns.getRecord().getIdentity()+' to '+endDate.getRecord().getIdentity());