如何使用orientjs对OrientDB执行Gremlin?
在Node中,对数据库执行Gremlin查询的正确方法是什么?
我目前使用Official Node OrientDB Driver的尝试:
const { ODatabase } = require('orientjs');
const db = new ODatabase({...});
db.query('g.V()')
.then(console.log, console.error);
我得到:
OrientDB.RequestError:
Cannot find a command executor for the command request: sql.g.V()
DB name="mynevo"
at child.Operation.parseError
(.../orientjs/lib/transport/binary/protocol33/operation.js:864:13)
但是,当我在Web界面中执行g.V()
时,它运行得很好。
显然,Node驱动程序或服务器假定查询应该是SQL。有没有办法告诉它是Gremlin,还是有其他方法?
回答如下:您应该能够使用执行gremlin命令
```
db.query('g.V()', {
language : "gremlin",
class : "com.orientechnologies.orient.graph.gremlin.OCommandGremlin"
}).then(function(res){
console.log(res);
})
```