[英]Cayley: How do insert vertices and edges into graph using Cayley-Gremlin code?
[英]How to start a new connection with CosmoDB graph database using gremlin on version ^3
我使用最新的gremlin lib连接到cosmos db。 这是我的代码:
const authenticator = new Gremlin.driver.auth.PlainTextSaslAuthenticator(
config.user,
config.password
);
const endpoint = `wss://${config.host}:${config.port}/gremlin`;
const client = new Gremlin.driver.Client(endpoint, {
authenticator,
mimeType: 'application/vnd.gremlin-v2.0+json',
rejectUnauthorized: true,
traversalsource: 'g',
});
然后,您可以使用以下命令向服务器提交一个返回promise的命令:
query = 'g.V().count()';
client.submit(query).then(successfn,errorfn);
使用的配置格式如下:
{ "host": "<cosmosdbname>.gremlin.cosmosdb.azure.com", "password": "<secret-key>", "port": 443, "user": "/dbs/<dbname>/colls/<collectionName>", }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.