Node.js 如何使用orientjs对OrientDB执行Gremlin?

Node.js 如何使用orientjs对OrientDB执行Gremlin?,node.js,orientdb,gremlin,Node.js,Orientdb,Gremlin,在Node中,对数据库执行查询的正确方法是什么 我当前使用的尝试: const{ODatabase}=require('orientjs'); const db=新的ODatabase({…}); db.query('g.V()')) .然后(console.log,console.error); 我得到: OrientDB.RequestError: Cannot find a command executor for the command request: sql.g.V()

在Node中,对数据库执行查询的正确方法是什么

我当前使用的尝试:

const{ODatabase}=require('orientjs');
const db=新的ODatabase({…});
db.query('g.V()'))
.然后(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()
时,它工作得非常好


显然,节点驱动程序或服务器假定查询是SQL。有没有办法告诉它是Gremlin,或者有其他方法?

您应该能够使用

```


```

对OrientDB执行gremlin查询最简单、最快速的方法是使用REST API(端口2480,而不是二进制端口2424)。 这是一个电话,我建议先在邮递员那里试试

[POST]http://:2480/command//gremlin

然后请求主体可以如下所示:

{
    "command": "g.V().has('name', 'marko')"
}
将OrientDB凭据作为基本身份验证传递

在NodeJS/JavaScript中,只需使用superagent或类似模块来调用RESTAPI。然后分析作为JSON返回的结果

另见:


请查看命令部分

谢谢!另外,您知道如何注入参数吗?无论我尝试什么,它都会说“类:Script17没有这样的属性:p1”。。。例如:
g.V().has('name',p1)
with
{params:{p1:'Alan'}}
{
    "command": "g.V().has('name', 'marko')"
}