Skip to content

CosmosDB support? #42

@Kubera2017

Description

@Kubera2017

Hello, does this library support CosmosDB?

I tried, actually it needs GraphSONSerializersV2d0 instead of V3, I used grammes.WithGremlinVersion(2) for that, vertices are added, but retreival queries don't work, it returns empty labels and IDs. This is test code:

package main

import (
	"fmt"
	"log"

	"github.com/northwesternmutual/grammes"
)

func main() {
	cosmosdb_account := "g123"
	cosmosdb_password := "J7q==" // Primary key from Keys
	cosmosdb_database := "db"    // In Data Explorer, need to create yours
	cosmosdb_graph := "test" // In Data Explorer, need to create yours

	cosmosdb_partition_key := "partition_key" // the same as you set when creating the graph in Data Explorer
	cosmosdb_partition_value := "1"

	host := "wss://" + cosmosdb_account + ".gremlin.cosmosdb.azure.com:443/"
	username := "/dbs/" + cosmosdb_database + "/colls/" + cosmosdb_graph
	password := cosmosdb_password

	client, err := grammes.DialWithWebSocket(host,
		grammes.WithAuthUserPass(username, password),
		grammes.WithGremlinVersion(2),
	)
	if err != nil {
		log.Fatal(err.Error())
	}

	_, err = client.AddVertex("test", cosmosdb_partition_key, cosmosdb_partition_value)
	if err != nil {
		log.Fatal("failed to add vertex", err.Error())
	}

	g := grammes.Traversal()
	vertices, err := client.VerticesByQuery(g.V())
	if err != nil {
		log.Fatal("Couldn't gather vertices", err.Error())
	}

	for _, vertex := range vertices {
		fmt.Println(vertex.Label(), vertex.ID())
	}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions