如何通过sails-orientdb适配器运行OrientDB功能?
带有签名的水线方法有一个扩展名 .runFunction('FunctionName', args...) 但我无法使用我的用例。
我的OrientDB函数通过它的id:
返回给定用户顶点的朋友var db = orient.getGraph();
return db.command("sql", "select expand(unionall(outE('IsFriendsWith').inV(), inE('IsFriendsWith').outV())) from " + id);
我在UserController控制器中的操作调用了我的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.log(req.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工作室得到这个结果,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,"
}
]
我真的不知道该怎么做。我刚刚开始使用帆和水线。提前谢谢!