You might have to make series of REST calls in this case, 1 request each to 
create the vertices, 1 request each to update vertex with the LINKs 
pointing to the other vertex and another to create the edge. Note that you 
would need to set the property "out_RELATION" on the source vertex and 
"in_RELATION" on the target vertex (where RELATION is the class of the edge 
you want to create). Also set the propertyies "in" and "out" on the edge.

// create the vertices (note down @rid and @version created)
curl -i -X POST -d '{@class : "Person", name : "nagu"}' 
http://admin:admin@localhost:2480/document/tempdb
curl -i -X POST -d '{@class : "Car", model : "Polo"}' 
http://admin:admin@localhost:2480/document/tempdb

// use the below query, if required, to get the vertices @rid, @version

curl -i -X GET 
http://admin:admin@localhost:2480/query/tempdb/sql/select%20from%20Person%20where%20name%3D%22nagu%22
curl -i -X GET 
http://admin:admin@localhost:2480/query/tempdb/sql/select%20from%20Car%20where%20model%3D%22Polo%22

// update in_ and out_ props 

curl -i -X PUT -d '{@class : "Person", @version : '8', out_Owns : [#44:4]}' 
http://admin:admin@localhost:2480/document/tempdb/43:2?updateMode=partial
curl -i -X PUT -d '{@class : "Car", @version : '10', in_Owns : [#43:2]}' 
http://admin:admin@localhost:2480/document/tempdb/44:4?updateMode=partial

// now create the edge

curl -i -X POST -d '{@class : "Owns", in : #43:2, out : #44:4}' 
http://admin:admin@localhost:2480/document/tempdb


cheers!


On Friday, April 10, 2015 at 3:18:13 PM UTC+5:30, Sunny K wrote:
>
> I have my Json as :-
>
> { @class : 'Account', name : 'Luca', vehicles : [ { @class : 'Vehicle', 
> type : 'Car', model : 'Maserati', isItTrue: false } ] }
>
> I want to create an edge( not link ) between account and vehicle. How can 
> I acheive this? i have tried document.fromJson(myjson) , but it creates a 
> link and not separate vertices.  If not possible by this json format, Can u 
> please provide a json format, using which i can create account and vehicle 
> vertices and relationship between them. Thanks.
>

-- 

--- 
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