计算 orientdb 中的边嵌入 javascript 函数

countEdges in oriendb embeded javascript function

我有一个函数可以在此处嵌入 JavaScript

var gdb = orient.getGraph();
var retour = {};
try{
  var login = gdb.getVertex(id);
  if(login){
// ----- insert controle here -------
    var pays = login.getLabel().slice(-2);
    var Ccompte = gdb.getVertexType("Compte_".concat(pays))|| gdb.createVertexType("Compte_".concat(pays),"Compte");
    var Cconfig = gdb.getVertexType("Config_".concat(pays))|| gdb.createVertexType("Config_".concat(pays),"Config");  
    var compte = gdb.addVertex("class:"+Ccompte);
      compte.setProperty("Pays",pays);
    var config = gdb.addVertex("class:"+Cconfig);
      config.setProperty("Nom","message");
      config.setProperty("Desc","Service Messagerie");
    login.addEdge("Membre",compte)
    login.addEdge("MP", config );
    gdb.commit();

    retour.ID =  compte.getId();
    retour.pays = pays;
  }  
  else{
    retour.err = 'Compte Introuvable';
    retour.errcode = 152;
  }
} catch(err) {
  gdb.rollback();
  retour.err = err.toString();
  retour.errcode = 201
} finally {
  gdb.shutdown();
}
return retour;

我是控件插入边数

if ( login.countEdges (Direction.OUT, "Membre")== 0 ) {.....

这里是countEdges的描述

public long countEdges(Direction iDirection,String... iLabels)   (Blueprints Extension) Returns the number of edges connected to the current Vertex.

    Parameters:
        iDirection - The direction between OUT, IN or BOTH
        iLabels - Optional labels as Strings to consider
    Returns:
        A long with the total edges found

我的类型方向有误 (错误 = "ReferenceError: \"方向\"未定义")

如果有人有我感兴趣的想法

谢谢

您可以尝试替换

if ( login.countEdges (Direction.OUT, "Membre")== 0 ) {.....

var edge=login.getRecord().field("out_Membre");
if(edge==null || edge.size()==0){ ...