使用Gremlin javascript驱动程序连接到OrientDB

使用Gremlin javascript驱动程序连接到OrientDB,orientdb,gremlin,tinkerpop,tinkerpop3,Orientdb,Gremlin,Tinkerpop,Tinkerpop3,我正在努力寻找一个使用OrientDB的当前gremlin javascript驱动程序的示例。我无法让它连接到OrientDB(已经在使用tinkerpop启用的版本) 我的示例代码如下所示: const gremlin = require("gremlin") const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection const graph = new gremlin.structure.Graph() con

我正在努力寻找一个使用OrientDB的当前gremlin javascript驱动程序的示例。我无法让它连接到OrientDB(已经在使用tinkerpop启用的版本)

我的示例代码如下所示:

const gremlin = require("gremlin")
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection

const graph = new gremlin.structure.Graph()
const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/demodb'))

g.V().toList().then(function(data) {
   console.log(data)
}).catch(function(err) {
   console.log(err)
})

有人有一起使用这些工具的经验吗?谢谢

如果您想通过Gremlin连接OrientDB,请尝试以下操作:

Local -> gremlin> g = new OrientGraph("plocal:db_path/nomeDB")

In-Memory -> gremlin> g = new OrientGraph("memory:nomeDB")

Remote -> gremlin> g = new OrientGraph("remote:localhost/nomeDB")
希望能有帮助


关于

我挖了一点。Gremlin Javascript驱动程序不支持GraphSON3

将其添加到server.yaml序列化程序配置中,以添加对v2的支持

- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.orientdb.io.OrientIoRegistry] }}  
然后它应该会工作

试试这个:

import * as gremlin from 'gremlin';
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;

const authenticator = new gremlin.driver.auth.PlainTextSaslAuthenticator(<db username>, <db password>);
const traversal = gremlin.process.AnonymousTraversalSource.traversal;

const g = traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin', {
      authenticator: authenticator
    }));
import*作为来自“gremlin”的gremlin;
const DriverRemoteConnection=gremlin.driver.DriverRemoteConnection;
const authenticator=new gremlin.driver.auth.plaintextsalauthenticator(,);
const traversal=gremlin.process.AnonymousTraversalSource.traversal;
const g=traversal().withRemote(新的DriverRemoteConnection('ws://localhost:8182/gremlin'){
验证者:验证者
}));
请注意url中的
/gremlin
,而不是
/demodab
。 要指向
demodab
或其他数据库,请从OrientDB修改
config
文件夹中的
demodab.properties
文件


如果您想创建另一个属性文件,请记住在
gremlin server.yaml
文件中指向它。

您遇到了什么问题?你能运行嵌入OrientDB TP3 Edition的GremlinServer吗?是的,我能通过gremlin控制台连接到db,但不能通过gremlin javascript驱动程序。你有重现这个的要点吗?谢谢谢谢谢谢你,米歇尔!我能够通过gremlin控制台连接到db,但是我无法让gremlin javascript驱动程序工作。[npmjs.com/package/gremlin]我用示例代码更新了我的原始问题。这不适用于javascript。仅用于控制台。gremlin npm包现在指向官方TinkerPop3 javascript驱动程序(jbnusso的verison已被弃用),该驱动程序支持GraphSON3。但是,我尝试了v2序列化程序,得到了相同的结果:
Vertex{id:'#33:0',label:'',properties:undefined}
NPM支持图SON3上的包可用吗?我是在对gremlin Server 3.3.1使用gremlin javascript 3.2.9时得到这个结果的。错误:服务器错误(无请求信息):请求的OpProcessor无效[null](499)根据git repo[,它在2个月前获得了GraphSON3支持。但是,defaultMimeType是v2,因此在启动新的DriverRemoteConnection时必须提供一个options对象,或者在driver-remote-connection.js中用“application/vnd.gremlin-v3.0+json”覆盖defaultMimeType我猜。我已经用V3 mimeType const g=graph.traversal()运行了您的测试。withRemote(新的DriverRemoteConnection('ws://localhost:8182/gremlin',{mimeType:'application/vnd.gremlin-V3.0+json'}))仍然会得到一个空数组作为响应,即使顶点在服务器上。我避免了OrientDB,并使用了gremlin-server-classic.yaml