I used a javascript function to abstract edge creation from JSON data sent 
from Angular.  

I was having trouble extracting relevant data from my JSON (needed because 
of the avstraction) and Alessandro posted this reply - which works perfectly

I hope that it helps you.  This forum is really great for anybody trying to 
get to grips with Orient!
=================
try this function with the parameter record {"from_rid": "#12:0","to_rid": 
"12:1", "edge_type": 
"friend","edge_properties":{"property1":"value_property", 
"property2":"value2_property"}}

var obj = JSON.parse(record);
var ridFrom=  obj.from_rid;
var ridTo = obj.to_rid;
var edge_type= obj.edge_type;
var edge_properties= obj.edge_properties;
var property1=edge_properties.property1;
var property2=edge_properties.property2;
var set=" set "+Object.keys(edge_properties)[0] + " = '" + property1 + "', 
" + 
    Object.keys(edge_properties)[1] + " = '" + property2 + "'"
var query="create edge "+ edge_type + " from " + ridFrom + " to " + ridTo + 
set ;
var g=orient.getGraph();
g.command('sql',query);

Alessandro
===========================================

On Wednesday, 5 August 2015 03:52:47 UTC+1, loadedlux wrote:
>
> Is it not possible to create an edge from JSON using the graph API?
>
> On Wednesday, July 22, 2015 at 8:08:27 AM UTC-4, loadedlux wrote:
>>
>> Yes. But I would like to use JSON to create the edge.
>>
>> On Wednesday, July 22, 2015 at 3:28:20 AM UTC-4, Giulia Brignoli wrote:
>>>
>>> Hi loadedlux,
>>>
>>> I'm not very clear what you want:
>>> you want to create an edge between two vertex using GraphAPI, right?
>>>
>>> Bye
>>> Giulia
>>>
>>

-- 

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