如何通过sails OrientDB适配器调用OrientDB函数?

如何通过sails OrientDB适配器调用OrientDB函数?,orientdb,oriento,sails-orientdb,Orientdb,Oriento,Sails Orientdb,如何通过sails OrientDB适配器运行OrientDB函数 有一个带有签名的waterline方法的扩展 但是我不能让它与我的用例一起工作 My OrientDB函数通过其id返回给定用户顶点的好友: var db = orient.getGraph(); return db.command("sql", "select expand(unionall(outE('IsFriendsWith').inV(), inE('IsFriendsWith').outV())) from "

如何通过sails OrientDB适配器运行OrientDB函数

有一个带有签名的waterline方法的扩展 但是我不能让它与我的用例一起工作

My OrientDB函数通过其id返回给定用户顶点的好友:

var db = orient.getGraph(); 

return db.command("sql", "select expand(unionall(outE('IsFriendsWith').inV(), inE('IsFriendsWith').outV())) from " + id);
UserController中的我的操作调用My orientDB函数:

findFriends: function (req, res, next) {
    console.log(req.param('id'));
    User.runFunction('findFriends', '#' + req.param('id')).from('OUser').limit(20).one()
        .then(function (result) {
                res.json(result);
    });
}
我错过什么了吗

console.logreq.param'id'返回33:288786

我在orientdb控制台中获得以下日志:

    Cannot serialize record: #-2:0{findFriends:[3]} v0 [ONetworkProtocolBinary]{db=database} Error on unmarshalling record #-2:0 (java.lang.ClassCastException: com.tinkerpop.blueprints.impls.orient.OrientVertex cannot be cast to com.orientechnologies.orient.core.record.ORecord)
java.lang.ClassCastException: com.tinkerpop.blueprints.impls.orient.OrientVertex cannot be cast to com.orientechnologies.orient.core.record.ORecord
    at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.fieldTypeToString(ORecordSerializerStringAbstract.java:197)
    at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerCSVAbstract.embeddedCollectionToStream(ORecordSerializerCSVAbstract.java:843)
    at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerCSVAbstract.fieldToStream(ORecordSerializerCSVAbstract.java:534)
    at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV.toString(ORecordSerializerSchemaAware2CSV.java:506)
    at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.toStream(ORecordSerializerStringAbstract.java:688)
    at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerSchemaAware2CSV.toStream(ORecordSerializerSchemaAware2CSV.java:268)
    at com.orientechnologies.orient.core.record.impl.ODocument.toStream(ODocument.java:2102)
    at com.orientechnologies.orient.core.record.impl.ODocument.toStream(ODocument.java:714)
    at com.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.getRecordBytes(OBinaryNetworkProtocolAbstract.java:417)
    at com.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.writeRecord(OBinaryNetworkProtocolAbstract.java:432)
    at com.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.writeIdentifiable(OBinaryNetworkProtocolAbstract.java:136)
    at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.command(ONetworkProtocolBinary.java:1226)
    at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:386)
    at com.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.execute(OBinaryNetworkProtocolAbstract.java:217)
    at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:69
错误告诉我需要将结果转换为记录

我在OrientDB studio中获得此结果,id为33:288786:

    [
    {
        "@type": "d",
        "@rid": "#33:288787",
        "@version": 16,
        "@class": "User",
        "gender": false,
        "mail": "1",
        "no": "1",
        "moto": "1",
        "rel": "1",
        "ori": "1",
        "pass": "1",
        "birthDate": null,
        "online": false,
        "name": "1",
        "in_IsFriendsWith": [
            "#23:4"
        ],
        "@fieldTypes": "in_IsFriendsWith=g,"
    }
]

我真不知道该怎么办。我刚开始使用帆和水线。提前谢谢

Alex,有几个问题:req.param'id'的值是多少?可以添加console.log进行检查吗?您的函数是否在OrientDB studio/console中工作?是,该函数在此处的函数选项卡中工作,id参数为33:288786。我传递给它的请求参数'id'是33:288786,然后我在控制器操作的开头添加了。我更新了我的问题