我苦苦寻找使用当前小鬼JavaScript的驱动程序OrientDB一个例子。我无法得到它连接到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)
})
是否有人有使用这些共同的经验吗?谢谢
如果你想连接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")
希望能帮助到你
问候
我挖一点点。小鬼的Javascript驱动程序不支持GraphSON3
https://github.com/jbmusso/gremlin-javascript/issues/109
添加到您的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
}));
请注意在URL中/gremlin
,不/demodb
。指向demodb
或其他数据库修改从OrientDB的demodb.properties
文件夹中的文件config
。
如果你愿意,你可以创建另一个属性文件,只记得指向它在gremlin-server.yaml
文件。