[英]how to add multiple edges using javascript function in orientDB
I have added multiple nodes using the javascript function and wish to add edges to connect them when I try to write a for loop, it throws the following exception: 我使用javascript函数添加了多个节点,并希望在尝试编写for循环时添加连接它们的边,它会引发以下异常:
com.orientechnologies.orient.core.exception.OSerializationException: Impossible to serialize invalid link :#57:-2 in embedded session
com.orientechnologies.orient.core.exception.OSerializationException:无法在嵌入式会话中序列化无效链接:#57:-2
If I write the same query without the for loop, it gets executed. 如果我编写相同的查询而没有for循环,它将被执行。
var g = orient.getGraph();
for (var i = 0 ; i < 5 ; i ++ ){
var title ="post_0";
var company_name = "Company_0";
var c = "create edge HasInterest from (select from post where Title = '" +
title + "') to (select from Interest where Name = 'Recruitment')";
g.command("sql",c,[]);
}
You are missing a commit() statement since you're using a loop as such: 由于使用了这样的循环,因此缺少了commit()语句:
var g = orient.getGraph();
for (var i = 0 ; i < 5 ; i ++ )
{
var title = "post_" + i;
var company_name = "Company_" + i;
var c = "create edge HasInterest from (select from post where Title = '" +
title + "') to (select from Interest where Name = 'Recruitment')";
g.command("sql",c,[]);
g.commit();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.