![](/img/trans.png)
[英]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.